NOTE
TreeSet
Sorted/navigable set semantics, comparator ordering, and logarithmic tree operations.
This is a historical learning note and may contain outdated or incomplete understanding.
TreeSet is a sorted NavigableSet, commonly backed by a TreeMap-style balanced tree.
Membership and updates are logarithmic. Ordering is defined by natural ordering or a comparator, and comparator equality determines whether two values occupy the same set position.
Use it for sorted iteration and range/navigation operations; otherwise HashSet is usually simpler.