The NavigableMap Interface in java

The NavigableMap interface was added by Java SE 6. It extends SortedMap and declares the behavior of a map that supports the retrieval of entries based on the closest match to a given key or keys. NavigableMap is a generic interface that has this declaration:

interface NavigableMap<K,V>

Here, K specifies the type of the keys, and V specifies the type of the values associated with the keys.

MethodDescription
Map.Entry<K,V> ceilingEntry(K obj)Searches the map for the smallest key k such that k >= obj. If such a key
 is found, its entry is returned. Otherwise, null is returned.
  
K ceilingKey(K obj)Searches the map for the smallest key k such that k >= obj. If such a key
 is found, it is returned. Otherwise, null is returned.
  
NavigableSet<K> descendingKeySet( )Returns a NavigableSet that contains the keys in the invoking map in
 reverse order. Thus, it returns a reverse set-view of the keys. The
 resulting set is backed by the map.
  
NavigableMap<K,V> descendingMap( )Returns a NavigableMap that is the reverse of the invoking map. The
 resulting map is backed by the invoking map.
  
Map.Entry<K,V> firstEntry( )Returns the first entry in the map. This is the entry with the least key.
  
Map.Entry<K,V> floorEntry(K obj)Searches the map for the largest key k such that k <= obj. If such a key
 is found, its entry is returned. Otherwise, null is returned.
  
K floorKey(K obj)Searches the map for the largest key k such that k <= obj. If such a key
 is found, it is returned. Otherwise, null is returned.
  
NavigableMap<K,V>Returns a NavigableMap that includes all entries from the invoking map
headMap(K upperBound, boolean incl)that have keys that are less than upperBound. If incl is true, then an
 element equal to upperBound is included. The resulting map is backed by
 the invoking map.
  
Map.Entry<K,V> higherEntry(K obj)Searches the set for the largest key k such that k > obj. If such a key is
 found, its entry is returned. Otherwise, null is returned.
 Method Description 
 K higherKey(K obj)Searches the set for the largest key k such that k > obj. If such a key is 
   found, it is returned. Otherwise, null is returned. 
    
 Map.Entry<K,V> lastEntry( )Returns the last entry in the map. This is the entry with the largest key. 
    
 Map.Entry<K,V> lowerEntry(K obj)Searches the set for the largest key k such that k < obj. If such a key is 
   found, its entry is returned. Otherwise, null is returned. 
    
 K lowerKey(K obj)Searches the set for the largest key k such that k < obj. If such a key is 
   found, it is returned. Otherwise, null is returned. 
    
 NavigableSet<K> navigableKeySet( )Returns a NavigableSet that contains the keys in the invoking map. The 
   resulting set is backed by the invoking map. 
    
 Map.Entry<K,V> pollFirstEntry( )Returns the first entry, removing the entry in the process. Because the 
   map is sorted, this is the entry with the least key value. null is returned if 
   the map is empty. 
    
 Map.Entry<K,V> pollLastEntry( )Returns the last entry, removing the entry in the process. Because the 
   map is sorted, this is the entry with the greatest key value. null is 
   returned if the map is empty. 
    
 NavigableMap<K,V>Returns a NavigableMap that includes all entries from the invoking map 
 subMap(K lowerBound,that have keys that are greater than lowerBound and less than 
 boolean lowIncl,upperBound. If lowIncl is true, then an element equal to lowerBound is 
 K upperBoundincluded. If highIncl is true, then an element equal to highIncl is included. 
 boolean highIncl)The resulting map is backed by the invoking map. 
    
 NavigableMap<K,V>Returns a NavigableMap that includes all entries from the invoking map 
 tailMap(K lowerBound, boolean incl)that have keys that are greater than lowerBound. If incl is true, then an 
   element equal to lowerBound is included. The resulting map is backed by 
   the invoking map. 

Leave a Comment