TreeMap class Methods in Java Part -I

java.util.TreeMap

A Red-Black tree-based NavigableMap implementation. The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.


Some methods of TreeMap class


ceilingEntry(Integer)This method returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.


ceilingKey(Integer)This method returns the least key greater than or equal to the given key, or null if there is no such key.


clear()This method removes all of the mappings from this map.


clone()This method returns a shallow copy of this TreeMap instance. 


comparator()This method returns the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys.


compute(K, BiFunction)This method attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).


computeIfAbsent(K, Function)If the specified key is not already associated with a value (or is mapped to null), attempt to compute its value using the given mapping function and enter it into this map unless null.


computeIfPresent(K, BiFunction)If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.


containsKey(Object)This method returns true if this map contains a mapping for the specified key.


containsValue(Object)This method returns true if this map maps one or more keys to the specified value.


descendingKeySet()This method returns a reverse order NavigableSet view of the keys contained in this map.


descendingMap()This method returns a reverse order view of the mappings contained in this map.


entrySet()This method returns a Set view of the mappings contained in this map.


firstEntry()This method returns a key-value mapping associated with the least key in this map, or null if the map is empty.


firstKey()This method returns the first (lowest) key currently on this map.


Some more Methods of TreeMap class Part-II


Some more Methods of TreeMap class Part-III




No comments:

Post a Comment