Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.emory.mathcs.backport.java.util
Class TreeMap

    java.lang.Object
      java.util.AbstractMap
          edu.emory.mathcs.backport.java.util.AbstractMap
              edu.emory.mathcs.backport.java.util.TreeMap

All Implemented Interfaces:
  java.util.Map, NavigableMap, java.io.Serializable, java.util.SortedMap

public class TreeMap
extends AbstractMap
implements NavigableMap, java.io.Serializable

Sorted map implementation based on a red-black tree and implementing all the methods from the NavigableMap interface.

Author:
  Dawid Kurzyniec
See Also:
  Serialized Form

Nested Class Summary
`static class` | `TreeMap.Entry`

Nested classes inherited from class edu.emory.mathcs.backport.java.util.AbstractMap
`AbstractMap.SimpleEntry, AbstractMap.SimpleImmutableEntry`

Constructor Summary
`TreeMap()`
`TreeMap(java.util.Comparator comparator)`
`TreeMap(java.util.Map map)`
`TreeMap(java.util.SortedMap map)`

Method Summary
`java.util.Map.Entry` | `ceilingEntry(java.lang.Object key)` Returns a key-value mapping associated with the least key greater than or equal to the given key, or if there is no such key.
`java.lang.Object` | `ceilingKey(java.lang.Object key)` Returns the least key greater than or equal to the given key, or if there is no such key.
`void` | `clear()`
`java.lang.Object` | `clone()`
`java.util.Comparator` | `comparator()`
`boolean` | `containsKey(java.lang.Object key)`
`boolean` | `containsValue(java.lang.Object value)`
`NavigableSet` | `descendingKeySet()` Returns a reverse order `NavigableSet` view of the keys contained in this map.
`NavigableMap` | `descendingMap()` Returns a reverse order view of the mappings contained in this map.
`java.util.Set` | `entrySet()`
`java.util.Map.Entry` | `firstEntry()` Returns a key-value mapping associated with the least key in this map, or if the map is empty.
`java.lang.Object` | `firstKey()`
`java.util.Map.Entry` | `floorEntry(java.lang.Object key)` Returns a key-value mapping associated with the greatest key less than or equal to the given key, or if there is no such key.
`java.lang.Object` | `floorKey(java.lang.Object key)` Returns the greatest key less than or equal to the given key, or if there is no such key.
`java.lang.Object` | `get(java.lang.Object key)`
`java.util.SortedMap` | `headMap(java.lang.Object toKey)` Equivalent to .
`NavigableMap` | `headMap(java.lang.Object toKey, boolean toInclusive)` Returns a view of the portion of this map whose keys are less than (or equal to, if is true) .
`java.util.Map.Entry` | `higherEntry(java.lang.Object key)` Returns a key-value mapping associated with the least key strictly greater than the given key, or if there is no such key.
`java.lang.Object` | `higherKey(java.lang.Object key)` Returns the least key strictly greater than the given key, or if there is no such key.
`boolean` | `isEmpty()`
`java.util.Set` | `keySet()`
`java.util.Map.Entry` | `lastEntry()` Returns a key-value mapping associated with the greatest key in this map, or if the map is empty.
`java.lang.Object` | `lastKey()`
`java.util.Map.Entry` | `lowerEntry(java.lang.Object key)` Returns a key-value mapping associated with the greatest key strictly less than the given key, or if there is no such key.
`java.lang.Object` | `lowerKey(java.lang.Object key)` Returns the greatest key strictly less than the given key, or if there is no such key.
`NavigableSet` | `navigableKeySet()` Returns a `NavigableSet` view of the keys contained in this map.
`java.util.Map.Entry` | `pollFirstEntry()` Removes and returns a key-value mapping associated with the least key in this map, or if the map is empty.
`java.util.Map.Entry` | `pollLastEntry()` Removes and returns a key-value mapping associated with the greatest key in this map, or if the map is empty.
`java.lang.Object` | `put(java.lang.Object key, java.lang.Object value)`
`void` | `putAll(java.util.Map map)`
`java.lang.Object` | `remove(java.lang.Object key)`
`int` | `size()`
`NavigableMap` | `subMap(java.lang.Object fromKey, boolean fromInclusive, java.lang.Object toKey, boolean toInclusive)` Returns a view of the portion of this map whose keys range from to .
`java.util.SortedMap` | `subMap(java.lang.Object fromKey, java.lang.Object toKey)` Equivalent to .
`java.util.SortedMap` | `tailMap(java.lang.Object fromKey)` Equivalent to .
`NavigableMap` | `tailMap(java.lang.Object fromKey, boolean fromInclusive)` Returns a view of the portion of this map whose keys are greater than (or equal to, if is true) .

Methods inherited from class java.util.AbstractMap
`equals, hashCode, toString, values`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode, values`

Constructor Detail

### TreeMap

    public TreeMap()

### TreeMap

    public TreeMap(java.util.Comparator comparator)

### TreeMap

    public TreeMap(java.util.SortedMap map)

### TreeMap

    public TreeMap(java.util.Map map)

Method Detail

### size

    public int size()

  Specified by:
    `size` in interface `java.util.Map`

### clear

    public void clear()

  Specified by:
    `clear` in interface `java.util.Map`

### clone

    public java.lang.Object clone()

### put

    public java.lang.Object put(java.lang.Object key,
                                java.lang.Object value)

  Specified by:
    `put` in interface `java.util.Map`

### get

    public java.lang.Object get(java.lang.Object key)

  Specified by:
    `get` in interface `java.util.Map`

### containsKey

    public boolean containsKey(java.lang.Object key)

  Specified by:
    `containsKey` in interface `java.util.Map`

### entrySet

    public java.util.Set entrySet()

  Specified by:
    `entrySet` in interface `java.util.Map`

### lowerEntry

    public java.util.Map.Entry lowerEntry(java.lang.Object key)

  Description copied from interface: `NavigableMap`
  Returns a key-value mapping associated with the greatest key strictly less than the given key, or if there is no such key.

  Specified by:
    `lowerEntry` in interface `NavigableMap`
  Parameters:
    `key` - the key
  Returns:
    an entry with the greatest key less than , or if there is no such key
  Since:
    1.6

### lowerKey

    public java.lang.Object lowerKey(java.lang.Object key)

  Description copied from interface: `NavigableMap`
  Returns the greatest key strictly less than the given key, or if there is no such key.

  Specified by:
    `lowerKey` in interface `NavigableMap`
  Parameters:
    `key` - the key
  Returns:
    the greatest key less than , or if there is no such key
  Since:
    1.6

### floorEntry

    public java.util.Map.Entry floorEntry(java.lang.Object key)

  Description copied from interface: `NavigableMap`
  Returns a key-value mapping associated with the greatest key less than or equal to the given key, or if there is no such key.

  Specified by:
    `floorEntry` in interface `NavigableMap`
  Parameters:
    `key` - the key
  Returns:
    an entry with the greatest key less than or equal to , or if there is no such key
  Since:
    1.6

### floorKey

    public java.lang.Object floorKey(java.lang.Object key)

  Description copied from interface: `NavigableMap`
  Returns the greatest key less than or equal to the given key, or if there is no such key.

  Specified by:
    `floorKey` in interface `NavigableMap`
  Parameters:
    `key` - the key
  Returns:
    the greatest key less than or equal to , or if there is no such key
  Since:
    1.6

### ceilingEntry

    public java.util.Map.Entry ceilingEntry(java.lang.Object key)

  Description copied from interface: `NavigableMap`
  Returns a key-value mapping associated with the least key greater than or equal to the given key, or if there is no such key.

  Specified by:
    `ceilingEntry` in interface `NavigableMap`
  Parameters:
    `key` - the key
  Returns:
    an entry with the least key greater than or equal to , or if there is no such key
  Since:
    1.6

### ceilingKey

    public java.lang.Object ceilingKey(java.lang.Object key)

  Description copied from interface: `NavigableMap`
  Returns the least key greater than or equal to the given key, or if there is no such key.

  Specified by:
    `ceilingKey` in interface `NavigableMap`
  Parameters:
    `key` - the key
  Returns:
    the least key greater than or equal to , or if there is no such key
  Since:
    1.6

### higherEntry

    public java.util.Map.Entry higherEntry(java.lang.Object key)

  Description copied from interface: `NavigableMap`
  Returns a key-value mapping associated with the least key strictly greater than the given key, or if there is no such key.

  Specified by:
    `higherEntry` in interface `NavigableMap`
  Parameters:
    `key` - the key
  Returns:
    an entry with the least key greater than , or if there is no such key
  Since:
    1.6

### higherKey

    public java.lang.Object higherKey(java.lang.Object key)

  Description copied from interface: `NavigableMap`
  Returns the least key strictly greater than the given key, or if there is no such key.

  Specified by:
    `higherKey` in interface `NavigableMap`
  Parameters:
    `key` - the key
  Returns:
    the least key greater than , or if there is no such key
  Since:
    1.6

### firstEntry

    public java.util.Map.Entry firstEntry()

  Description copied from interface: `NavigableMap`
  Returns a key-value mapping associated with the least key in this map, or if the map is empty.

  Specified by:
    `firstEntry` in interface `NavigableMap`
  Returns:
    an entry with the least key, or if this map is empty
  Since:
    1.6

### lastEntry

    public java.util.Map.Entry lastEntry()

  Description copied from interface: `NavigableMap`
  Returns a key-value mapping associated with the greatest key in this map, or if the map is empty.

  Specified by:
    `lastEntry` in interface `NavigableMap`
  Returns:
    an entry with the greatest key, or if this map is empty
  Since:
    1.6

### pollFirstEntry

    public java.util.Map.Entry pollFirstEntry()

  Description copied from interface: `NavigableMap`
  Removes and returns a key-value mapping associated with the least key in this map, or if the map is empty.

  Specified by:
    `pollFirstEntry` in interface `NavigableMap`
  Returns:
    the removed first entry of this map, or if this map is empty
  Since:
    1.6

### pollLastEntry

    public java.util.Map.Entry pollLastEntry()

  Description copied from interface: `NavigableMap`
  Removes and returns a key-value mapping associated with the greatest key in this map, or if the map is empty.

  Specified by:
    `pollLastEntry` in interface `NavigableMap`
  Returns:
    the removed last entry of this map, or if this map is empty
  Since:
    1.6

### descendingMap

    public NavigableMap descendingMap()

  Description copied from interface: `NavigableMap`
  Returns a reverse order view of the mappings contained in this map. The descending map is backed by this map, so changes to the map are reflected in the descending map, and vice-versa. If either map is modified while an iteration over a collection view of either map is in progress (except through the iterator's own operation), the results of the iteration are undefined.

  The returned map has an ordering equivalent to ``Collections.reverseOrder`(comparator())`. The expression returns a view of essentially equivalent to .

  Specified by:
    `descendingMap` in interface `NavigableMap`
  Returns:
    a reverse order view of this map
  Since:
    1.6

### descendingKeySet

    public NavigableSet descendingKeySet()

  Description copied from interface: `NavigableMap`
  Returns a reverse order `NavigableSet` view of the keys contained in this map. The set's iterator returns the keys in descending order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the , , , , and operations. It does not support the or operations.

  Specified by:
    `descendingKeySet` in interface `NavigableMap`
  Returns:
    a reverse order navigable set view of the keys in this map

### subMap

    public java.util.SortedMap subMap(java.lang.Object fromKey,
                                      java.lang.Object toKey)

  Description copied from interface: `NavigableMap`

  Equivalent to .

  Specified by:
    `subMap` in interface `NavigableMap`

### headMap

    public java.util.SortedMap headMap(java.lang.Object toKey)

  Description copied from interface: `NavigableMap`

  Equivalent to .

  Specified by:
    `headMap` in interface `NavigableMap`

### tailMap

    public java.util.SortedMap tailMap(java.lang.Object fromKey)

  Description copied from interface: `NavigableMap`

  Equivalent to .

  Specified by:
    `tailMap` in interface `NavigableMap`

### subMap

    public NavigableMap subMap(java.lang.Object fromKey,
                               boolean fromInclusive,
                               java.lang.Object toKey,
                               boolean toInclusive)

  Description copied from interface: `NavigableMap`
  Returns a view of the portion of this map whose keys range from to . If and are equal, the returned map is empty unless and are both true. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

  The returned map will throw an on an attempt to insert a key outside of its range, or to construct a submap either of whose endpoints lie outside its range.

  Specified by:
    `subMap` in interface `NavigableMap`
  Parameters:
    `fromKey` - low endpoint of the keys in the returned map
    `fromInclusive` - if the low endpoint is to be included in the returned view
    `toKey` - high endpoint of the keys in the returned map
    `toInclusive` - if the high endpoint is to be included in the returned view
  Returns:
    a view of the portion of this map whose keys range from to

### headMap

    public NavigableMap headMap(java.lang.Object toKey,
                                boolean toInclusive)

  Description copied from interface: `NavigableMap`
  Returns a view of the portion of this map whose keys are less than (or equal to, if is true) . The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

  The returned map will throw an on an attempt to insert a key outside its range.

  Specified by:
    `headMap` in interface `NavigableMap`
  Parameters:
    `toKey` - high endpoint of the keys in the returned map
    `toInclusive` - if the high endpoint is to be included in the returned view
  Returns:
    a view of the portion of this map whose keys are less than (or equal to, if is true)

### tailMap

    public NavigableMap tailMap(java.lang.Object fromKey,
                                boolean fromInclusive)

  Description copied from interface: `NavigableMap`
  Returns a view of the portion of this map whose keys are greater than (or equal to, if is true) . The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

  The returned map will throw an on an attempt to insert a key outside its range.

  Specified by:
    `tailMap` in interface `NavigableMap`
  Parameters:
    `fromKey` - low endpoint of the keys in the returned map
    `fromInclusive` - if the low endpoint is to be included in the returned view
  Returns:
    a view of the portion of this map whose keys are greater than (or equal to, if is true)

### comparator

    public java.util.Comparator comparator()

  Specified by:
    `comparator` in interface `java.util.SortedMap`

### firstKey

    public java.lang.Object firstKey()

  Specified by:
    `firstKey` in interface `java.util.SortedMap`

### lastKey

    public java.lang.Object lastKey()

  Specified by:
    `lastKey` in interface `java.util.SortedMap`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `java.util.Map`

### containsValue

    public boolean containsValue(java.lang.Object value)

  Specified by:
    `containsValue` in interface `java.util.Map`

### remove

    public java.lang.Object remove(java.lang.Object key)

  Specified by:
    `remove` in interface `java.util.Map`

### putAll

    public void putAll(java.util.Map map)

  Specified by:
    `putAll` in interface `java.util.Map`

### keySet

    public java.util.Set keySet()

  Description copied from class: `AbstractMap`

  Specified by:
    `keySet` in interface `java.util.Map`
  Overrides:
    `keySet` in class `AbstractMap`

### navigableKeySet

    public NavigableSet navigableKeySet()

  Description copied from interface: `NavigableMap`
  Returns a `NavigableSet` view of the keys contained in this map. The set's iterator returns the keys in ascending order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the , , , , and operations. It does not support the or operations.

  Specified by:
    `navigableKeySet` in interface `NavigableMap`
  Returns:
    a navigable set view of the keys in this map

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD