# Interface NavigableMap<K,V>

Type Parameters:
  `K` - the type of key
  `V` - the type of value

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

All Known Implementing Classes:
  `TreeMap`

public interface NavigableMap<K,V> extends SortedMap<K,V>
NavigableMap is a SortedMap with navigation methods answering the closest matches for specified item.

Since:
  1.6

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Map

  `Map.Entry<K,V>`
  Modifier and Type
  Interface
  Description
  `static interface`
  `Map.Entry<K,V>`
  `Map.Entry` is a key/value mapping contained in a `Map`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Map.Entry<K,V>`
  `ceilingEntry(K key)`
  Answers an entry related with the smallest key greater than or equal to the specified key, or null if no such key.
  `K`
  `ceilingKey(K key)`
  Answers the smallest key greater than or equal to the specified key, or null if no such key.
  `NavigableSet<K>`
  `descendingKeySet()`
  Answers a NavigableSet view of the keys in descending order.
  `NavigableMap<K,V>`
  `descendingMap()`
  Answers a reverse order view of the map.
  `Map.Entry<K,V>`
  `firstEntry()`
  Answers the entry with the smallest key, or null if the map is empty.
  `Map.Entry<K,V>`
  `floorEntry(K key)`
  Answers an entry related with the biggest key less than or equal to the specified key, or null if no such key.
  `K`
  `floorKey(K key)`
  Answers the biggest key less than or equal to the specified key, or null if no such key.
  `NavigableMap<K,V>`
  `headMap(K endKey, boolean inclusive)`
  Answers a view of the head of the map whose keys are smaller than (or equal to, depends on inclusive argument) endKey.
  `Map.Entry<K,V>`
  `higherEntry(K key)`
  Answers an entry related with the smallest key greater than the specified key, or null if no such key.
  `K`
  `higherKey(K key)`
  Answers the smallest key greater than the specified key, or null if no such key.
  `Map.Entry<K,V>`
  `lastEntry()`
  Answers the entry with the biggest key, or null if the map is empty.
  `Map.Entry<K,V>`
  `lowerEntry(K key)`
  Answers an entry related with the biggest key less than the specified key, or null if no such key.
  `K`
  `lowerKey(K key)`
  Answers the biggest key less than the specified key, or null if no such key.
  `NavigableSet<K>`
  `navigableKeySet()`
  Answers a NavigableSet view of the keys in ascending order.
  `Map.Entry<K,V>`
  `pollFirstEntry()`
  Deletes and answers the entry with the smallest key, or null if the map is empty.
  `Map.Entry<K,V>`
  `pollLastEntry()`
  Deletes and answers the entry with the biggest key, or null if the map is empty.
  `NavigableMap<K,V>`
  `subMap(K startKey, boolean startInclusive, K endKey, boolean endInclusive)`
  Answers a view of part of the map whose keys is from startKey to endKey.
  `NavigableMap<K,V>`
  `tailMap(K startKey, boolean inclusive)`
  Answers a view of the tail of the map whose keys are bigger than (or equal to, depends on inclusive argument) startKey.

  ### Methods inherited from interface Map

  `clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values`
  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  Removes all elements from this `Map`, leaving it empty.
  `boolean`
  `containsKey(Object key)`
  Returns whether this `Map` contains the specified key.
  `boolean`
  `containsValue(Object value)`
  Returns whether this `Map` contains the specified value.
  `Set<Map.Entry<K,V>>`
  `entrySet()`
  Returns a `Set` containing all of the mappings in this `Map`.
  `boolean`
  `equals(Object object)`
  Compares the argument to the receiver, and returns `true` if the specified object is a `Map` and both `Map`s contain the same mappings.
  `V`
  `get(Object key)`
  Returns the value of the mapping with the specified key.
  `int`
  `hashCode()`
  Returns an integer hash code for the receiver.
  `boolean`
  `isEmpty()`
  Returns whether this map is empty.
  `Set<K>`
  `keySet()`
  Returns a set of the keys contained in this `Map`.
  `V`
  `put(K key, V value)`
  Maps the specified key to the specified value.
  `void`
  `putAll(Map<? extends K, ? extends V> map)`
  Copies every mapping in the specified `Map` to this `Map`.
  `V`
  `remove(Object key)`
  Removes a mapping with the specified key from this `Map`.
  `int`
  `size()`
  Returns the number of mappings in this `Map`.
  `Collection<V>`
  `values()`
  Returns a `Collection` of the values contained in this `Map`.

  ### Methods inherited from interface SortedMap

  `comparator, firstKey, headMap, lastKey, subMap, tailMap`
  Modifier and Type
  Method
  Description
  `Comparator<? super K>`
  `comparator()`
  Returns the comparator used to compare keys in this sorted map.
  `K`
  `firstKey()`
  Returns the first key in this sorted map.
  `SortedMap<K,V>`
  `headMap(K endKey)`
  Returns a sorted map over a range of this sorted map with all keys that are less than the specified `endKey`.
  `K`
  `lastKey()`
  Returns the last key in this sorted map.
  `SortedMap<K,V>`
  `subMap(K startKey, K endKey)`
  Returns a sorted map over a range of this sorted map with all keys greater than or equal to the specified `startKey` and less than the specified `endKey`.
  `SortedMap<K,V>`
  `tailMap(K startKey)`
  Returns a sorted map over a range of this sorted map with all keys that are greater than or equal to the specified `startKey`.

- ## Method Details

  - ### firstEntry

    Map.Entry<K,V> firstEntry()
    Answers the entry with the smallest key, or null if the map is empty.
    Returns:
      the entry with the smallest key, or null if the map is empty

  - ### lastEntry

    Map.Entry<K,V> lastEntry()
    Answers the entry with the biggest key, or null if the map is empty.
    Returns:
      the entry with the biggest key, or null if the map is empty

  - ### pollFirstEntry

    Map.Entry<K,V> pollFirstEntry()
    Deletes and answers the entry with the smallest key, or null if the map is empty.
    Returns:
      the entry with the smallest key, or null if the map is empty

  - ### pollLastEntry

    Map.Entry<K,V> pollLastEntry()
    Deletes and answers the entry with the biggest key, or null if the map is empty.
    Returns:
      the entry with the biggest key, or null if the map is empty

  - ### ceilingEntry

    Map.Entry<K,V> ceilingEntry(K key)
    Answers an entry related with the smallest key greater than or equal to the specified key, or null if no such key.
    Parameters:
      `key` - the key
    Returns:
      the entry, or null if no such key
    Throws:
      `ClassCastException` - if the key cannot be compared with the keys in the map
      `NullPointerException` - if the key is null and the map can not contain null key

  - ### ceilingKey

    K ceilingKey(K key)
    Answers the smallest key greater than or equal to the specified key, or null if no such key.
    Parameters:
      `key` - the key
    Returns:
      the smallest key greater than or equal to key, or null if no such key
    Throws:
      `ClassCastException` - if the key cannot be compared with the keys in the map
      `NullPointerException` - if the key is null and the map can not contain null key

  - ### higherEntry

    Map.Entry<K,V> higherEntry(K key)
    Answers an entry related with the smallest key greater than the specified key, or null if no such key.
    Parameters:
      `key` - the key
    Returns:
      the entry, or null if no such key
    Throws:
      `ClassCastException` - if the key cannot be compared with the keys in the map
      `NullPointerException` - if the key is null and the map can not contain null key

  - ### higherKey

    K higherKey(K key)
    Answers the smallest key greater than the specified key, or null if no such key.
    Parameters:
      `key` - the key
    Returns:
      the smallest key greater than key, or null if no such key
    Throws:
      `ClassCastException` - if the key cannot be compared with the keys in the map
      `NullPointerException` - if the key is null and the map can not contain null key

  - ### floorEntry

    Map.Entry<K,V> floorEntry(K key)
    Answers an entry related with the biggest key less than or equal to the specified key, or null if no such key.
    Parameters:
      `key` - the key
    Returns:
      the entry, or null if no such key
    Throws:
      `ClassCastException` - if the key cannot be compared with the keys in the map
      `NullPointerException` - if the key is null and the map can not contain null key

  - ### floorKey

    K floorKey(K key)
    Answers the biggest key less than or equal to the specified key, or null if no such key.
    Parameters:
      `key` - the key
    Returns:
      the biggest key less than or equal to key, or null if no such key
    Throws:
      `ClassCastException` - if the key cannot be compared with the keys in the map
      `NullPointerException` - if the key is null and the map can not contain null key

  - ### lowerEntry

    Map.Entry<K,V> lowerEntry(K key)
    Answers an entry related with the biggest key less than the specified key, or null if no such key.
    Parameters:
      `key` - the key
    Returns:
      the entry, or null if no such key
    Throws:
      `ClassCastException` - if the key cannot be compared with the keys in the map
      `NullPointerException` - if the key is null and the map can not contain null key

  - ### lowerKey

    K lowerKey(K key)
    Answers the biggest key less than the specified key, or null if no such key.
    Parameters:
      `key` - the key
    Returns:
      the biggest key less than key, or null if no such key
    Throws:
      `ClassCastException` - if the key cannot be compared with the keys in the map
      `NullPointerException` - if the key is null and the map can not contain null key

  - ### navigableKeySet

    NavigableSet<K> navigableKeySet()
    Answers a NavigableSet view of the keys in ascending order.
    Returns:
      the navigable set view

  - ### descendingMap

    NavigableMap<K,V> descendingMap()
    Answers a reverse order view of the map.
    Returns:
      the reverse order view of the map

  - ### descendingKeySet

    NavigableSet<K> descendingKeySet()
    Answers a NavigableSet view of the keys in descending order.
    Returns:
      the navigable set view

  - ### subMap

    NavigableMap<K,V> subMap(K startKey, boolean startInclusive, K endKey, boolean endInclusive)
    Answers a view of part of the map whose keys is from startKey to endKey.
    Parameters:
      `startKey` - the start key
      `startInclusive` - true if the start key is in the returned map
      `endKey` - the end key
      `endInclusive` - true if the end key is in the returned map
    Returns:
      the sub-map view
    Throws:
      `ClassCastException` - when the class of the start or end key is inappropriate for this SubMap
      `NullPointerException` - when the start or end key is null and this SortedMap does not support null keys
      `IllegalArgumentException` - when the start key is greater than the end key

  - ### headMap

    NavigableMap<K,V> headMap(K endKey, boolean inclusive)
    Answers a view of the head of the map whose keys are smaller than (or equal to, depends on inclusive argument) endKey.
    Parameters:
      `endKey` - the end key
      `inclusive` - true if the end key is in the returned map
    Returns:
      the head-map view
    Throws:
      `ClassCastException` - when the class of the end key is inappropriate for this SubMap
      `NullPointerException` - when the end key is null and this SortedMap does not support null keys
      `IllegalArgumentException` - when the map is range-limited and end key is out of the range of the map

  - ### tailMap

    NavigableMap<K,V> tailMap(K startKey, boolean inclusive)
    Answers a view of the tail of the map whose keys are bigger than (or equal to, depends on inclusive argument) startKey.
    Parameters:
      `startKey` - the start key
      `inclusive` - true if the start key is in the returned map
    Returns:
      the tail-map view
    Throws:
      `ClassCastException` - when the class of the start key is inappropriate for this SubMap
      `NullPointerException` - when the start key is null and this SortedMap does not support null keys
      `IllegalArgumentException` - when the map is range-limited and start key is out of the range of the map