linkedhashset.hLinkedHashSet class, which implements an efficient abstraction for storing sets of values.
A LinkedHashSet is the same as a HashSet, except that it exposes its values in the order they were inserted, rather than in the unpredictable order of a standard HashSet.
This is accomplished by storing the data in two ways internally: (1) in a hash table array, as in a HashSet; and (2) in a linear list, to remember the insertion order.
A LinkedHashSet provides identical lookup (contains) speed, nearly the same insertion (add) speed, and slower removal (remove) speed.
Its for-each loop and iterators emit the elements in the order they were added to the set, at the cost of the additional memory usage of the internal list.
| Class | |
| This class implements an efficient abstraction for storing sets of distinct elements and remembering insertion order. | |