HashSet and TreeSet are the two typical implementations of set, how do you choose HashSet and TreeSet? HashSet performance is always better than treeset (especially the most commonly used additions, query elements, and so on), because TreeSet small additional red-black tree algorithms to maintain the number of elements in the collection. You should use TreeSet only if you need a set that remains sorted, otherwise you should be using HashSet.
HashSet also has a subclass: Linkedhashset, for normal insert, delete operation, Linkedhashset is slightly slower than hashset, which is caused by the additional overhead of maintaining the list, but because of the linked list, Traversing Linkedhashset is faster.
Enumset is the best performance in any set implementation class, but it can only hold an enumeration value of the same enumeration class as a collection element
It must be noted that the three implementation classes of set are thread insecure, and if more than one thread accesses a set collection at the same time, and more than a single thread modifies the set set, you must manually guarantee the synchronization of the set set. The set collection can usually be "wrapped" by the Synchoronizedsortedset method of the Collections tool class.
38. Performance analysis of each set implementation class