Similarities:
1. All are ordered sets
2. TreeMap is the underlying structure of TreeSet
3. The running speed is slower than hash
the difference:
1. TreeSet only stores one object, while TreeMap stores two objects Key and Value (only key objects are ordered)
2. There cannot be duplicate objects in TreeSet, but it can exist in TreeMap.
3. The underlying layer of TreeMap adopts the implementation of red and black trees to complete the orderly insertion and sorting of data.
Features of PS Red and Black Tree:
1: Each node is either red/black.
2: The root node is black.
3: All leaf nodes are black empty nodes.
4: The two child nodes of each red node are black. (There will not be two consecutive red nodes on the path from each leaf to root)
5: The path from either node to each leaf node in its subtree contains the same number of black nodes.