|
|||||||||
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.SortedMap |
---|
values |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
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.Map
size
in class java.util.AbstractMap
public void clear()
clear
in interface java.util.Map
clear
in class java.util.AbstractMap
public 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.Map
put
in class java.util.AbstractMap
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
get
in class java.util.AbstractMap
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
containsKey
in class java.util.AbstractMap
public java.util.Set entrySet()
entrySet
in interface java.util.Map
entrySet
in interface java.util.SortedMap
entrySet
in class java.util.AbstractMap
public java.util.Map.Entry lowerEntry(java.lang.Object key)
NavigableMap
null
if there is
no such key.
lowerEntry
in interface NavigableMap
key
- the key
key
,
or null
if there is no such keypublic java.lang.Object lowerKey(java.lang.Object key)
NavigableMap
null
if there is no such key.
lowerKey
in interface NavigableMap
key
- the key
key
,
or null
if there is no such keypublic java.util.Map.Entry floorEntry(java.lang.Object key)
NavigableMap
null
if there
is no such key.
floorEntry
in interface NavigableMap
key
- the key
key
, or null
if there is no such keypublic java.lang.Object floorKey(java.lang.Object key)
NavigableMap
null
if there is no such key.
floorKey
in interface NavigableMap
key
- the key
key
,
or null
if there is no such keypublic java.util.Map.Entry ceilingEntry(java.lang.Object key)
NavigableMap
null
if
there is no such key.
ceilingEntry
in interface NavigableMap
key
- the key
key
, or null
if there is no such keypublic java.lang.Object ceilingKey(java.lang.Object key)
NavigableMap
null
if there is no such key.
ceilingKey
in interface NavigableMap
key
- the key
key
,
or null
if there is no such keypublic java.util.Map.Entry higherEntry(java.lang.Object key)
NavigableMap
null
if there
is no such key.
higherEntry
in interface NavigableMap
key
- the key
key
,
or null
if there is no such keypublic java.lang.Object higherKey(java.lang.Object key)
NavigableMap
null
if there is no such key.
higherKey
in interface NavigableMap
key
- the key
key
,
or null
if there is no such keypublic java.util.Map.Entry firstEntry()
NavigableMap
null
if the map is empty.
firstEntry
in interface NavigableMap
null
if this map is emptypublic java.util.Map.Entry lastEntry()
NavigableMap
null
if the map is empty.
lastEntry
in interface NavigableMap
null
if this map is emptypublic java.util.Map.Entry pollFirstEntry()
NavigableMap
null
if the map is empty.
pollFirstEntry
in interface NavigableMap
null
if this map is emptypublic java.util.Map.Entry pollLastEntry()
NavigableMap
null
if the map is empty.
pollLastEntry
in interface NavigableMap
null
if this map is emptypublic NavigableMap descendingMap()
NavigableMap
remove
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 NavigableMap
public NavigableSet descendingKeySet()
NavigableMap
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 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)
NavigableMap
Equivalent to subMap(fromKey, true, toKey, false)
.
subMap
in interface NavigableMap
subMap
in interface java.util.SortedMap
public java.util.SortedMap headMap(java.lang.Object toKey)
NavigableMap
Equivalent to headMap(toKey, false)
.
headMap
in interface NavigableMap
headMap
in interface java.util.SortedMap
public java.util.SortedMap tailMap(java.lang.Object fromKey)
NavigableMap
Equivalent to tailMap(fromKey, true)
.
tailMap
in interface NavigableMap
tailMap
in interface java.util.SortedMap
public NavigableMap subMap(java.lang.Object fromKey, boolean fromInclusive, java.lang.Object toKey, boolean toInclusive)
NavigableMap
fromKey
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 NavigableMap
fromKey
- 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)
NavigableMap
inclusive
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 NavigableMap
toKey
- 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)
NavigableMap
inclusive
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 NavigableMap
fromKey
- 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) fromKey
public java.util.Comparator comparator()
comparator
in interface java.util.SortedMap
public java.lang.Object firstKey()
firstKey
in interface java.util.SortedMap
public java.lang.Object lastKey()
lastKey
in interface java.util.SortedMap
public boolean isEmpty()
isEmpty
in interface java.util.Map
isEmpty
in class java.util.AbstractMap
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
containsValue
in class java.util.AbstractMap
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
remove
in class java.util.AbstractMap
public void putAll(java.util.Map map)
putAll
in interface java.util.Map
putAll
in class java.util.AbstractMap
public java.util.Set keySet()
AbstractMap
keySet
in interface java.util.Map
keySet
in interface java.util.SortedMap
keySet
in class AbstractMap
public NavigableSet navigableKeySet()
NavigableMap
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 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 |