| |
9. 21. 1. TreeSet类 |
|
- The other concrete Set implementation is the TreeSet.
- A TreeSet keeps its elements ordered internally.
- The tree is balanced, it's a red-black tree.
- Having a balanced tree guarantees a quick o(log n) search time at the cost of a more time-intensive
insertion (and deletion).
- Elements added to the tree must be orderable.
|
Red-black tree rules refresher: |
- Every node in the tree is either black or red.
- The root is always black.
- If a node is red, its children must be black.
- Every path from the root to a leaf (or null child) must contain the same number of black nodes.
(referenced from "Java Collections by John Zukowski Apress 2001")
|
|