• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

LinkedHashSet is an ordered set

 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic