|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap
org.compass.core.util.backport.java.util.AbstractMap
org.compass.core.util.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 | |
|---|---|
(package private) class |
TreeMap.AscendingKeySet
|
(package private) class |
TreeMap.AscendingSubMap
|
(package private) class |
TreeMap.DescendingEntryIterator
|
(package private) class |
TreeMap.DescendingEntrySet
|
(package private) class |
TreeMap.DescendingKeyIterator
|
(package private) class |
TreeMap.DescendingKeySet
|
(package private) class |
TreeMap.DescendingSubMap
|
(package private) class |
TreeMap.DescendingValueIterator
|
static class |
TreeMap.Entry
|
(package private) class |
TreeMap.EntryIterator
|
(package private) class |
TreeMap.EntrySet
|
(package private) static class |
TreeMap.IOIterator
|
(package private) static class |
TreeMap.IteratorIOException
|
(package private) static class |
TreeMap.IteratorNoClassException
|
(package private) class |
TreeMap.KeyIterator
|
(package private) class |
TreeMap.KeySet
|
(package private) class |
TreeMap.ValueIterator
|
(package private) class |
TreeMap.ValueSet
|
| Nested classes/interfaces inherited from class org.compass.core.util.backport.java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry, AbstractMap.SimpleImmutableEntry |
| Field Summary |
|---|
| Fields inherited from class org.compass.core.util.backport.java.util.AbstractMap |
|---|
keySet |
| Constructor Summary | |
|---|---|
TreeMap()
|
|
TreeMap(Comparator comparator)
|
|
TreeMap(Map map)
|
|
TreeMap(SortedMap map)
|
|
| Method Summary | |
|---|---|
(package private) void |
buildFromSorted(Iterator itr,
int size)
|
Map.Entry |
ceilingEntry(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. |
Object |
ceilingKey(Object key)
Returns the least key greater than or equal to the given key, or null if there is no such key. |
void |
clear()
|
Object |
clone()
|
(package private) static boolean |
colorOf(TreeMap.Entry p)
Return color of node p, or BLACK if p is null (In the CLR version, they use a special dummy `nil' node for such purposes, but that doesn't work well here, since it could lead to creating one such special node per real node.) |
Comparator |
comparator()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(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. |
Set |
entrySet()
|
Map.Entry |
firstEntry()
Returns a key-value mapping associated with the least key in this map, or null if the map is empty. |
Object |
firstKey()
|
Map.Entry |
floorEntry(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. |
Object |
floorKey(Object key)
Returns the greatest key less than or equal to the given key, or null if there is no such key. |
Object |
get(Object key)
|
SortedMap |
headMap(Object toKey)
Equivalent to headMap(toKey, false). |
NavigableMap |
headMap(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. |
Map.Entry |
higherEntry(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. |
Object |
higherKey(Object key)
Returns the least key strictly greater than the given key, or null if there is no such key. |
boolean |
isEmpty()
|
Set |
keySet()
|
Map.Entry |
lastEntry()
Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty. |
Object |
lastKey()
|
Map.Entry |
lowerEntry(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. |
Object |
lowerKey(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. |
(package private) static TreeMap.Entry |
parentOf(TreeMap.Entry p)
return parent of node p, or null if p is null |
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. |
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. |
Object |
put(Object key,
Object value)
|
void |
putAll(Map map)
|
Object |
remove(Object key)
|
(package private) Comparator |
reverseComparator()
|
int |
size()
|
NavigableMap |
subMap(Object fromKey,
boolean fromInclusive,
Object toKey,
boolean toInclusive)
Returns a view of the portion of this map whose keys range from fromKey to toKey. |
SortedMap |
subMap(Object fromKey,
Object toKey)
Equivalent to subMap(fromKey, true, toKey, false). |
SortedMap |
tailMap(Object fromKey)
Equivalent to tailMap(fromKey, true). |
NavigableMap |
tailMap(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(Comparator comparator)
public TreeMap(SortedMap map)
public TreeMap(Map map)
| Method Detail |
|---|
public int size()
size in interface Mapsize in class AbstractMappublic void clear()
clear in interface Mapclear in class AbstractMappublic Object clone()
clone in class AbstractMap
public Object put(Object key,
Object value)
put in interface Mapput in class AbstractMappublic Object get(Object key)
get in interface Mapget in class AbstractMappublic boolean containsKey(Object key)
containsKey in interface MapcontainsKey in class AbstractMappublic Set entrySet()
entrySet in interface MapentrySet in class AbstractMap
void buildFromSorted(Iterator itr,
int size)
static boolean colorOf(TreeMap.Entry p)
static TreeMap.Entry parentOf(TreeMap.Entry p)
public Map.Entry lowerEntry(Object key)
NavigableMapnull if there is
no such key.
lowerEntry in interface NavigableMapkey - the key
key,
or null if there is no such keypublic Object lowerKey(Object key)
NavigableMapnull if there is no such key.
lowerKey in interface NavigableMapkey - the key
key,
or null if there is no such keypublic Map.Entry floorEntry(Object key)
NavigableMapnull if there
is no such key.
floorEntry in interface NavigableMapkey - the key
key, or null if there is no such keypublic Object floorKey(Object key)
NavigableMapnull if there is no such key.
floorKey in interface NavigableMapkey - the key
key,
or null if there is no such keypublic Map.Entry ceilingEntry(Object key)
NavigableMapnull if
there is no such key.
ceilingEntry in interface NavigableMapkey - the key
key, or null if there is no such keypublic Object ceilingKey(Object key)
NavigableMapnull if there is no such key.
ceilingKey in interface NavigableMapkey - the key
key,
or null if there is no such keypublic Map.Entry higherEntry(Object key)
NavigableMapnull if there
is no such key.
higherEntry in interface NavigableMapkey - the key
key,
or null if there is no such keypublic Object higherKey(Object key)
NavigableMapnull if there is no such key.
higherKey in interface NavigableMapkey - the key
key,
or null if there is no such keypublic Map.Entry firstEntry()
NavigableMapnull if the map is empty.
firstEntry in interface NavigableMapnull if this map is emptypublic Map.Entry lastEntry()
NavigableMapnull if the map is empty.
lastEntry in interface NavigableMapnull if this map is emptypublic Map.Entry pollFirstEntry()
NavigableMapnull if the map is empty.
pollFirstEntry in interface NavigableMapnull if this map is emptypublic 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 SortedMap subMap(Object fromKey,
Object toKey)
NavigableMapEquivalent to subMap(fromKey, true, toKey, false).
subMap in interface SortedMapsubMap in interface NavigableMappublic SortedMap headMap(Object toKey)
NavigableMapEquivalent to headMap(toKey, false).
headMap in interface SortedMapheadMap in interface NavigableMappublic SortedMap tailMap(Object fromKey)
NavigableMapEquivalent to tailMap(fromKey, true).
tailMap in interface SortedMaptailMap in interface NavigableMap
public NavigableMap subMap(Object fromKey,
boolean fromInclusive,
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(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(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 Comparator comparator()
comparator in interface SortedMapfinal Comparator reverseComparator()
public Object firstKey()
firstKey in interface SortedMappublic Object lastKey()
lastKey in interface SortedMappublic boolean isEmpty()
isEmpty in interface MapisEmpty in class AbstractMappublic boolean containsValue(Object value)
containsValue in interface MapcontainsValue in class AbstractMappublic Object remove(Object key)
remove in interface Mapremove in class AbstractMappublic void putAll(Map map)
putAll in interface MapputAll in class AbstractMappublic Set keySet()
AbstractMap
keySet in interface 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 | |||||||||