chen-w
8/17/2017 - 9:58 PM

TreeMap class

TreeMap class

The TreeMap class implements the Map interface by using a tree. 
A TreeMap provides an efficient means of storing key/value pairs in sorted order, and allows rapid retrieval.

// initialization
TreeMap<Integer, List<Integer>> tree = new TreeMap<>();

tree.add()
tree.clear()
tree.containsKey()
tree.keySet()
tree.put(key, value)
tree.pollFirstEntry()
Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.
tree.pollLastEntry()
Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.