Noteworthy collections - rFronteddu/general_wiki GitHub Wiki
TreeSet
- TreeSet is a class in Java collection framework which implements the Set and NavigableSet interfaces and inherits AbstractSet.
- It only contains unique elements (null element is not allowed)
- Not synchronized (you can use Collections.synchronizedSet(treeSet) to make it synchronized);
- Maintains ascending order and uses Self Balancing Binary Search Tree (red/black) for storing elements.
- The time complexity for search/insert/delete is O(log n)
- Methods:
- E ceiling(E s): returns equal or closest greatest element or null if there is no such element.
- E floor(E s): returns equal or closest least element or null if there is no such element.
- Set headSet(E s): return elements of TreeSet which are less than the specified element.