Wednesday, 12 October 2016

What is NavigableMap In Java ?

This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.

Previously we have discussed about
What is SortedMap In Java ?


Here we learn what is NavigableMap in java.But before starting this you must know What is Map Interface in Java ?
Interface NavigableMap<K,V>

Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values

All Superinterfaces:
Map<K,V>, SortedMap<K,V>

All Known Subinterfaces:
ConcurrentNavigableMap<K,V>

All Known Implementing Classes:
ConcurrentSkipListMap, TreeMap

Declaration of NavigableMap: public interface NavigableMap<K,V>
extends SortedMap<K,V>

A NavigableMap may be accessed and traversed in either ascending or descending key order. The descendingMap method returns a view of the map with the senses of all relational and directional methods inverted. 
The performance of ascending operations and views is likely to be faster than that of descending ones. Methods subMap, headMap, and tailMap differ from the like-named SortedMap methods in accepting additional arguments describing whether lower and upper bounds are inclusive versus exclusive. Submaps of any NavigableMap must implement the NavigableMap interface.

This interface additionally defines methods firstEntry, pollFirstEntry, lastEntry, and pollLastEntry that return and/or remove the least and greatest mappings, if any exist, else returning null.

This interface is a member of the Java Collections Framework.

Method Summary of NavigableMap :

Modifier and Type
Method Name
Description
Map.Entry<K,V>
ceilingEntry(K key)
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.
K
ceilingKey(K key)
Returns the least key greater than or equal to the given key, or null if there is no such key.
NavigableSet<K>
NavigableSet<K>
Returns a reverse order NavigableSet view of the keys contained in this map.
descendingMap()
Returns a reverse order view of the mappings contained in this map.
Map.Entry<K,V>
Map.Entry<K,V>
Returns a reverse order view of the mappings contained in this map.
Map.Entry<K,V>               
firstEntry()
Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
Map.Entry<K,V>
floorEntry(K key)
Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
Map.Entry<K,V>
floorEntry(K key)
Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
K
floorKey(K key)
Returns the greatest key less than or equal to the given key, or null if there is no such key.
headMap(K toKey)
Returns a view of the portion of this map whose keys are strictly less than toKey.
NavigableMap<K,V>
headMap(K toKey, boolean inclusive)
Returns a view of the portion of this map whose keys are less than (or equal to, if inclusive is true) toKey.
cc Map.Entry<K,V>
higherEntry(K key)
Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.
K
higherKey(K key)
Returns the least key strictly greater than the given key, or null if there is no such key.
Map.Entry<K,V>
lastEntry()
Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
Map.Entry<K,V>
lowerEntry(K key)
Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.
K
lowerKey(K key)
Returns the greatest key strictly less than the given key, or null if there is no such key.
NavigableSet<K>
navigableKeySet()
Returns a NavigableSet view of the keys contained in this map.
Map.Entry<K,V>
pollFirstEntry()
Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.
Map.Entry<K,V>
pollLastEntry()
Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
NavigableMap<K,V>
subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
Returns a view of the portion of this map whose keys range from fromKey to toKey.
subMap(K fromKey, K toKey)
Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
tailMap(K fromKey)
Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
tailMap(K fromKey, boolean inclusive)
Returns a view of the portion of this map whose keys are greater than (or equal to, if inclusive is true) fromKey.

No comments:

Post a Comment