|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.TreeMap<K,V>
public class TreeMap<K,V>
TreeMap is an implementation of SortedMap. All optional operations are supported, adding and removing. The values can be any objects. The keys can be any objects which are comparable to each other either using their natural order or a specified Comparator.
| Nested Class Summary | |
|---|---|
(package private) static class |
TreeMap.Entry<K,V>
Entry is an internal class which is used to hold the entries of a TreeMap. |
(package private) static class |
TreeMap.SubMap<K,V>
|
(package private) static class |
TreeMap.SubMapEntrySet<K,V>
|
(package private) static class |
TreeMap.SubMapKeySet<K,V>
|
(package private) static class |
TreeMap.SubMapValuesCollection<K,V>
|
(package private) static class |
TreeMap.UnboundedKeyIterator<K,V>
|
(package private) static class |
TreeMap.UnboundedValueIterator<K,V>
|
| Field Summary | |
|---|---|
(package private) Set<Map.Entry<K,V>> |
entrySet
|
(package private) int |
modCount
|
(package private) TreeMap.Entry<K,V> |
root
|
(package private) int |
size
|
| Fields inherited from class java.util.AbstractMap |
|---|
keySet, valuesCollection |
| Constructor Summary | |
|---|---|
TreeMap()
Constructs a new empty instance of TreeMap. |
|
TreeMap(Comparator<? super K> comparator)
Constructs a new empty instance of TreeMap which uses the specified Comparator. |
|
TreeMap(Map<? extends K,? extends V> map)
Constructs a new instance of TreeMap containing the mappings from the specified Map and using the natural ordering. |
|
TreeMap(SortedMap<K,? extends V> map)
Constructs a new instance of TreeMap containing the mappings from the specified SortedMap and using the same Comparator. |
|
| Method Summary | ||
|---|---|---|
(package private) void |
balance(TreeMap.Entry<K,V> x)
|
|
void |
clear()
Removes all mappings from this TreeMap, leaving it empty. |
|
Object |
clone()
Returns a new TreeMap with the same mappings, size and comparator as this TreeMap. |
|
Comparator<? super K> |
comparator()
Returns the Comparator used to compare elements in this TreeMap. |
|
boolean |
containsKey(Object key)
Searches this TreeMap for the specified key. |
|
boolean |
containsValue(Object value)
Searches this TreeMap for the specified value. |
|
Set<Map.Entry<K,V>> |
entrySet()
Returns a Set of the mappings contained in this TreeMap. |
|
(package private) TreeMap.Entry<K,V> |
findAfter(Object keyObj)
|
|
(package private) TreeMap.Entry<K,V> |
findBefore(K key)
|
|
K |
firstKey()
Answer the first sorted key in this TreeMap. |
|
V |
get(Object key)
Returns the value of the mapping with the specified key. |
|
SortedMap<K,V> |
headMap(K endKey)
Returns a SortedMap of the specified portion of this TreeMap which contains keys less than the end key. |
|
Set<K> |
keySet()
Returns a Set of the keys contained in this TreeMap. |
|
K |
lastKey()
Answer the last sorted key in this TreeMap. |
|
(package private) static
|
maximum(TreeMap.Entry<K,V> x)
|
|
(package private) static
|
minimum(TreeMap.Entry<K,V> x)
|
|
(package private) static
|
predecessor(TreeMap.Entry<K,V> x)
|
|
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 TreeMap. |
|
(package private) void |
rbDelete(TreeMap.Entry<K,V> z)
|
|
V |
remove(Object key)
Removes a mapping with the specified key from this TreeMap. |
|
int |
size()
Returns the number of mappings in this TreeMap. |
|
SortedMap<K,V> |
subMap(K startKey,
K endKey)
Returns a SortedMap of the specified portion of this TreeMap which contains keys greater or equal to the start key but less than the end key. |
|
(package private) static
|
successor(TreeMap.Entry<K,V> x)
|
|
SortedMap<K,V> |
tailMap(K startKey)
Returns a SortedMap of the specified portion of this TreeMap which contains keys greater or equal to the start key. |
|
Collection<V> |
values()
Returns a Collection of the values contained in this TreeMap. |
|
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, isEmpty, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode, isEmpty |
| Field Detail |
|---|
transient int size
transient TreeMap.Entry<K,V> root
transient int modCount
transient Set<Map.Entry<K,V>> entrySet
| Constructor Detail |
|---|
public TreeMap()
public TreeMap(Comparator<? super K> comparator)
comparator - the Comparatorpublic TreeMap(Map<? extends K,? extends V> map)
map - the mappings to add
ClassCastException - when a key in the Map does not implement the Comparable
interface, or they keys in the Map cannot be comparedpublic TreeMap(SortedMap<K,? extends V> map)
map - the mappings to add| Method Detail |
|---|
void balance(TreeMap.Entry<K,V> x)
public void clear()
clear in interface Map<K,V>clear in class AbstractMap<K,V>Map.isEmpty(),
sizepublic Object clone()
clone in class AbstractMap<K,V>Cloneablepublic Comparator<? super K> comparator()
comparator in interface SortedMap<K,V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>key - the object to search for
key is a key of this TreeMap, false
otherwise
ClassCastException - when the key cannot be compared with the keys in this
TreeMap
NullPointerException - when the key is null and the comparator cannot handle nullpublic boolean containsValue(Object value)
containsValue in interface Map<K,V>containsValue in class AbstractMap<K,V>value - the object to search for
value is a value of this TreeMap, false
otherwisepublic Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>entrySet in class AbstractMap<K,V>TreeMap.Entry<K,V> findAfter(Object keyObj)
TreeMap.Entry<K,V> findBefore(K key)
public K firstKey()
firstKey in interface SortedMap<K,V>NoSuchElementException - when this TreeMap is emptypublic V get(Object key)
get in interface Map<K,V>get in class AbstractMap<K,V>key - the key
ClassCastException - when the key cannot be compared with the keys in this
TreeMap
NullPointerException - when the key is null and the comparator cannot handle nullpublic SortedMap<K,V> headMap(K endKey)
headMap in interface SortedMap<K,V>endKey - the end key
endKey
ClassCastException - when the end key cannot be compared with the keys in this
TreeMap
NullPointerException - when the end key is null and the comparator cannot handle
nullpublic Set<K> keySet()
keySet in interface Map<K,V>keySet in class AbstractMap<K,V>public K lastKey()
lastKey in interface SortedMap<K,V>NoSuchElementException - when this TreeMap is emptystatic <K,V> TreeMap.Entry<K,V> maximum(TreeMap.Entry<K,V> x)
static <K,V> TreeMap.Entry<K,V> minimum(TreeMap.Entry<K,V> x)
static <K,V> TreeMap.Entry<K,V> predecessor(TreeMap.Entry<K,V> x)
public V put(K key,
V value)
put in interface Map<K,V>put in class AbstractMap<K,V>key - the keyvalue - the value
ClassCastException - when the key cannot be compared with the keys in this
TreeMap
NullPointerException - when the key is null and the comparator cannot handle nullpublic void putAll(Map<? extends K,? extends V> map)
putAll in interface Map<K,V>putAll in class AbstractMap<K,V>map - the Map to copy mappings from
ClassCastException - when a key in the Map cannot be compared with the keys in
this TreeMap
NullPointerException - when a key in the Map is null and the comparator cannot
handle nullvoid rbDelete(TreeMap.Entry<K,V> z)
public V remove(Object key)
remove in interface Map<K,V>remove in class AbstractMap<K,V>key - the key of the mapping to remove
ClassCastException - when the key cannot be compared with the keys in this
TreeMap
NullPointerException - when the key is null and the comparator cannot handle nullpublic int size()
size in interface Map<K,V>size in class AbstractMap<K,V>
public SortedMap<K,V> subMap(K startKey,
K endKey)
subMap in interface SortedMap<K,V>startKey - the start keyendKey - the end key
startKey and less than endKey
ClassCastException - when the start or end key cannot be compared with the keys
in this TreeMap
NullPointerException - when the start or end key is null and the comparator
cannot handle nullstatic <K,V> TreeMap.Entry<K,V> successor(TreeMap.Entry<K,V> x)
public SortedMap<K,V> tailMap(K startKey)
tailMap in interface SortedMap<K,V>startKey - the start key
startKey
ClassCastException - when the start key cannot be compared with the keys in
this TreeMap
NullPointerException - when the start key is null and the comparator cannot
handle nullpublic Collection<V> values()
values in interface Map<K,V>values in class AbstractMap<K,V>
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||