| java.lang.Object | ||
| ↳ | java.util.AbstractMap<K, V> | |
| ↳ | java.util.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.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new empty instance of TreeMap.
| |||||||||||
Constructs a new empty instance of TreeMap which uses the specified
Comparator.
| |||||||||||
Constructs a new instance of TreeMap containing the mappings from the
specified Map and using the natural ordering.
| |||||||||||
Constructs a new instance of TreeMap containing the mappings from the
specified SortedMap and using the same Comparator.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Removes all mappings from this TreeMap, leaving it empty.
| |||||||||||
Returns a new TreeMap with the same mappings, size and comparator as this
TreeMap.
| |||||||||||
Returns the Comparator used to compare elements in this TreeMap.
| |||||||||||
Searches this TreeMap for the specified key.
| |||||||||||
Searches this TreeMap for the specified value.
| |||||||||||
Returns a Set of the mappings contained in this TreeMap.
| |||||||||||
Answer the first sorted key in this TreeMap.
| |||||||||||
Returns the value of the mapping with the specified key.
| |||||||||||
Returns a SortedMap of the specified portion of this TreeMap which
contains keys less than the end key.
| |||||||||||
Returns a Set of the keys contained in this TreeMap.
| |||||||||||
Answer the last sorted key in this TreeMap.
| |||||||||||
Maps the specified key to the specified value.
| |||||||||||
Copies every mapping in the specified Map to this TreeMap.
| |||||||||||
Removes a mapping with the specified key from this TreeMap.
| |||||||||||
Returns the number of mappings in this TreeMap.
| |||||||||||
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.
| |||||||||||
Returns a SortedMap of the specified portion of this TreeMap which
contains keys greater or equal to the start key.
| |||||||||||
Returns a Collection of the values contained in this TreeMap.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.util.AbstractMap
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.util.Map
| |||||||||||
From interface java.util.SortedMap
| |||||||||||
Constructs a new empty instance of TreeMap.
Constructs a new empty instance of TreeMap which uses the specified Comparator.
| comparator | the Comparator |
|---|
Constructs a new instance of TreeMap containing the mappings from the specified Map and using the natural ordering.
| 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 compared |
|---|
Constructs a new instance of TreeMap containing the mappings from the specified SortedMap and using the same Comparator.
| map | the mappings to add |
|---|
Returns a new TreeMap with the same mappings, size and comparator as this TreeMap.
Returns the Comparator used to compare elements in this TreeMap.
Searches this TreeMap for the specified key.
| 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 null |
Searches this TreeMap for the specified value.
| value | the object to search for |
|---|
value is a value of this TreeMap, false
otherwise
Returns a Set of the mappings contained in this TreeMap. Each element in the set is a Map.Entry. The set is backed by this TreeMap so changes to one are reflected by the other. The set does not support adding.
Answer the first sorted key in this TreeMap.
| NoSuchElementException | when this TreeMap is empty |
|---|
Returns the value of the mapping with the specified key.
| 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 null |
Returns a SortedMap of the specified portion of this TreeMap which contains keys less than the end key. The returned SortedMap is backed by this TreeMap so changes to one are reflected by the other.
| 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 null |
Returns a Set of the keys contained in this TreeMap. The set is backed by this TreeMap so changes to one are reflected by the other. The set does not support adding.
Answer the last sorted key in this TreeMap.
| NoSuchElementException | when this TreeMap is empty |
|---|
Maps the specified key to the specified value.
| key | the key |
|---|---|
| value | 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 null |
Copies every mapping in the specified Map to this TreeMap.
| 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 null |
Removes a mapping with the specified key from this TreeMap.
| 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 null |
Returns the number of mappings in this TreeMap.
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. The returned SortedMap is backed by this TreeMap so changes to one are reflected by the other.
| startKey | the start key |
|---|---|
| endKey | 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 null |
Returns a SortedMap of the specified portion of this TreeMap which contains keys greater or equal to the start key. The returned SortedMap is backed by this TreeMap so changes to one are reflected by the other.
| 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 null |
Returns a Collection of the values contained in this TreeMap. The collection is backed by this TreeMap so changes to one are reflected by the other. The collection does not support adding.