aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes LinkedHashSet is an ordered set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "LinkedHashSet is an ordered set" Watch "LinkedHashSet is an ordered set" New topic
Author

LinkedHashSet is an ordered set

Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
I am reading a book that says a LinkedHashSet is an ordered set.
We call a set sorted (SortedSet) when the iterator returns the elements sorted. So I suppose we can call a set ordered when the iterator returns the elements in some predictable order.
We know that a List is an ordered collection. We know that two instances of a List are *equal* if they contain the same elements *in the same order*.
However, two instances of a LinkedHashSet are equal if they contain the same elements, although the elements might not be in the same order.
The order is essential to the identity of a List instance. The order is not essential to the identity of a LinkedHashSet instance.
Saying a List is an ordered collection is different in degree from saying that a LinkedHashSet is an ordered set.
 
 
subject: LinkedHashSet is an ordered set