|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap
edu.emory.mathcs.backport.java.util.AbstractMap
edu.emory.mathcs.backport.java.util.TreeMap
public class TreeMap
Sorted map implementation based on a red-black tree and implementing all the methods from the NavigableMap interface.
| Nested Class Summary | |
|---|---|
static class |
TreeMap.Entry
|
| Nested classes/interfaces 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 null 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 null 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 null 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 null 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 null if there is no such key. |
java.lang.Object |
get(java.lang.Object key)
|
java.util.SortedMap |
headMap(java.lang.Object toKey)
|
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 inclusive is true) toKey. |
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 null 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 null 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 null 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 null 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 null 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 null 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 null 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 fromKey to toKey. |
java.util.SortedMap |
subMap(java.lang.Object fromKey,
java.lang.Object toKey)
|
java.util.SortedMap |
tailMap(java.lang.Object fromKey)
|
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 inclusive is true) fromKey. |
| 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 |
|---|
public TreeMap()
public TreeMap(java.util.Comparator comparator)
public TreeMap(java.util.SortedMap map)
public TreeMap(java.util.Map map)
| Method Detail |
|---|
public int size()
size in interface java.util.Mapsize in class java.util.AbstractMappublic void clear()
clear in interface java.util.Mapclear in class java.util.AbstractMappublic java.lang.Object clone()
clone in class java.util.AbstractMap
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
put in interface java.util.Mapput in class java.util.AbstractMappublic java.lang.Object get(java.lang.Object key)
get in interface java.util.Mapget in class java.util.AbstractMappublic boolean containsKey(java.lang.Object key)
containsKey in interface java.util.MapcontainsKey in class java.util.AbstractMappublic java.util.Set entrySet()
entrySet in interface java.util.MapentrySet in class java.util.AbstractMappublic java.util.Map.Entry lowerEntry(java.lang.Object key)
NavigableMapnull if there is
no such key.
lowerEntry in interface NavigableMapkey - the key
key,
or null if there is no such keypublic java.lang.Object lowerKey(java.lang.Object key)
NavigableMapnull if there is no such key.
lowerKey in interface NavigableMapkey - the key
key,
or null if there is no such keypublic java.util.Map.Entry floorEntry(java.lang.Object key)
NavigableMapnull if there
is no such key.
floorEntry in interface NavigableMapkey - the key
key, or null if there is no such keypublic java.lang.Object floorKey(java.lang.Object key)
NavigableMapnull if there is no such key.
floorKey in interface NavigableMapkey - the key
key,
or null if there is no such keypublic java.util.Map.Entry ceilingEntry(java.lang.Object key)
NavigableMapnull if
there is no such key.
ceilingEntry in interface NavigableMapkey - the key
key, or null if there is no such keypublic java.lang.Object ceilingKey(java.lang.Object key)
NavigableMapnull if there is no such key.
ceilingKey in interface NavigableMapkey - the key
key,
or null if there is no such keypublic java.util.Map.Entry higherEntry(java.lang.Object key)
NavigableMapnull if there
is no such key.
higherEntry in interface NavigableMapkey - the key
key,
or null if there is no such keypublic java.lang.Object higherKey(java.lang.Object key)
NavigableMapnull if there is no such key.
higherKey in interface NavigableMapkey - the key
key,
or null if there is no such keypublic java.util.Map.Entry firstEntry()
NavigableMapnull if the map is empty.
firstEntry in interface NavigableMapnull if this map is emptypublic java.util.Map.Entry lastEntry()
NavigableMapnull if the map is empty.
lastEntry in interface NavigableMapnull if this map is emptypublic java.util.Map.Entry pollFirstEntry()
NavigableMapnull if the map is empty.
pollFirstEntry in interface NavigableMapnull if this map is emptypublic java.util.Map.Entry pollLastEntry()
NavigableMapnull if the map is empty.
pollLastEntry in interface NavigableMapnull if this map is emptypublic NavigableMap descendingMap()
NavigableMapremove
operation), the results of the iteration are undefined.
The returned map has an ordering equivalent to
Collections.reverseOrder(comparator()).
The expression m.descendingMap().descendingMap() returns a
view of m essentially equivalent to m.
descendingMap in interface NavigableMappublic NavigableSet descendingKeySet()
NavigableMapNavigableSet 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 remove operation), the results of the iteration are undefined. The
set supports element removal, which removes the corresponding mapping
from the map, via the Iterator.remove, Set.remove,
removeAll, retainAll, and clear operations.
It does not support the add or addAll operations.
descendingKeySet in interface NavigableMap
public java.util.SortedMap subMap(java.lang.Object fromKey,
java.lang.Object toKey)
NavigableMapEquivalent to subMap(fromKey, true, toKey, false).
subMap in interface NavigableMapsubMap in interface java.util.SortedMappublic java.util.SortedMap headMap(java.lang.Object toKey)
NavigableMapEquivalent to headMap(toKey, false).
headMap in interface NavigableMapheadMap in interface java.util.SortedMappublic java.util.SortedMap tailMap(java.lang.Object fromKey)
NavigableMapEquivalent to tailMap(fromKey, true).
tailMap in interface NavigableMaptailMap in interface java.util.SortedMap
public NavigableMap subMap(java.lang.Object fromKey,
boolean fromInclusive,
java.lang.Object toKey,
boolean toInclusive)
NavigableMapfromKey to toKey. If fromKey and
toKey are equal, the returned map is empty unless
fromExclusive and toExclusive 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 IllegalArgumentException
on an attempt to insert a key outside of its range, or to construct a
submap either of whose endpoints lie outside its range.
subMap in interface NavigableMapfromKey - low endpoint of the keys in the returned mapfromInclusive - true if the low endpoint
is to be included in the returned viewtoKey - high endpoint of the keys in the returned maptoInclusive - true if the high endpoint
is to be included in the returned view
fromKey to toKey
public NavigableMap headMap(java.lang.Object toKey,
boolean toInclusive)
NavigableMapinclusive is true) toKey. 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 IllegalArgumentException
on an attempt to insert a key outside its range.
headMap in interface NavigableMaptoKey - high endpoint of the keys in the returned maptoInclusive - true if the high endpoint
is to be included in the returned view
inclusive is true) toKey
public NavigableMap tailMap(java.lang.Object fromKey,
boolean fromInclusive)
NavigableMapinclusive is true) fromKey. 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 IllegalArgumentException
on an attempt to insert a key outside its range.
tailMap in interface NavigableMapfromKey - low endpoint of the keys in the returned mapfromInclusive - true if the low endpoint
is to be included in the returned view
inclusive is true) fromKeypublic java.util.Comparator comparator()
comparator in interface java.util.SortedMappublic java.lang.Object firstKey()
firstKey in interface java.util.SortedMappublic java.lang.Object lastKey()
lastKey in interface java.util.SortedMappublic boolean isEmpty()
isEmpty in interface java.util.MapisEmpty in class java.util.AbstractMappublic boolean containsValue(java.lang.Object value)
containsValue in interface java.util.MapcontainsValue in class java.util.AbstractMappublic java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mapremove in class java.util.AbstractMappublic void putAll(java.util.Map map)
putAll in interface java.util.MapputAll in class java.util.AbstractMappublic java.util.Set keySet()
AbstractMap
keySet in interface java.util.MapkeySet in class AbstractMappublic NavigableSet navigableKeySet()
NavigableMapNavigableSet 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 remove operation), the results of the iteration are undefined. The
set supports element removal, which removes the corresponding mapping
from the map, via the Iterator.remove, Set.remove,
removeAll, retainAll, and clear operations.
It does not support the add or addAll operations.
navigableKeySet in interface NavigableMap
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||