Any implementation of Ordered Set in Java?

Take a look at LinkedHashSet class From Java doc: Hash table and linked list implementation of the Set interface, with predictable iteration order. This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is the order in which elements were inserted into the … Read more

Any implementation of Ordered Set in Java?

Take a look at LinkedHashSet class From Java doc: Hash table and linked list implementation of the Set interface, with predictable iteration order. This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is the order in which elements were inserted into the … Read more

Java Ordered Map

The SortedMap interface (with the implementation TreeMap) should be your friend. The interface has the methods: keySet() which returns a set of the keys in ascending order values() which returns a collection of all values in the ascending order of the corresponding keys So this interface fulfills exactly your requirements. However, the keys must have a meaningful order. Otherwise you … Read more

What are the differences between a HashMap and a Hashtable in Java?

There are several differences between HashMap and Hashtable in Java: Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values. One of HashMap’s subclasses is LinkedHashMap, so in the event that you’d want predictable iteration order (which is insertion order by default), you … Read more