|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.util
Class TreeMap.SubMap

java.lang.Objectjava.util.AbstractMap
java.util.TreeMap.SubMap
- Enclosing class:
- TreeMap
- private final class TreeMap.SubMap
- extends AbstractMap
- implements SortedMap
- extends AbstractMap
Implementation of subMap(Object, Object) 55 and other map
ranges. This class provides a view of a portion of the original backing
map, and throws java.lang.IllegalArgumentException for attempts to
access beyond that range.
| Nested Class Summary |
| Nested classes inherited from class java.util.AbstractMap |
AbstractMap.BasicMapEntry |
| Nested classes inherited from class java.util.Map |
Map.Entry |
| Field Summary | |
private Set |
entries
The cache for entrySet() 55 . |
(package private) java.lang.Object |
maxKey
The upper range of this view, exclusive, or nil for unbounded. |
(package private) java.lang.Object |
minKey
The lower range of this view, inclusive, or nil for unbounded. |
| Fields inherited from class java.util.AbstractMap |
ENTRIES, keys, KEYS, values, VALUES |
| Constructor Summary | |
(package private) |
TreeMap.SubMap(java.lang.Object minKey,
java.lang.Object maxKey)
Create a SubMap representing the elements between minKey (inclusive) and maxKey (exclusive). |
| Method Summary | |
void |
clear()
Remove all entries from this Map (optional operation). |
Comparator |
comparator()
Returns the comparator used in sorting this map, or null if it is the keys' natural ordering. |
boolean |
containsKey(java.lang.Object key)
Returns true if this contains a mapping for the given key. |
boolean |
containsValue(java.lang.Object value)
Returns true if this contains at least one mapping with the given value. |
Set |
entrySet()
Returns a set view of the mappings in this Map. |
java.lang.Object |
firstKey()
Returns the first (lowest sorted) key in the map. |
java.lang.Object |
get(java.lang.Object key)
Returns the value mapped by the given key. |
SortedMap |
headMap(java.lang.Object toKey)
Returns a view of the portion of the map strictly less than toKey. |
(package private) boolean |
keyInRange(java.lang.Object key)
Check if "key" is in within the range bounds for this SubMap. |
Set |
keySet()
Returns a set view of the keys in this Map. |
java.lang.Object |
lastKey()
Returns the last (highest sorted) key in the map. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the given key to the given value (optional operation). |
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key if present (optional operation). |
int |
size()
Returns the number of key-value mappings in the map. |
SortedMap |
subMap(java.lang.Object fromKey,
java.lang.Object toKey)
Returns a view of the portion of the map greater than or equal to fromKey, and strictly less than toKey. |
SortedMap |
tailMap(java.lang.Object fromKey)
Returns a view of the portion of the map greater than or equal to fromKey. |
Collection |
values()
Returns a collection (or bag) view of the values in this Map. |
| Methods inherited from class java.util.AbstractMap |
clone, equals, equals, hashCode, hashCode, isEmpty, putAll, 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, putAll |
| Field Detail |
minKey
final java.lang.Object minKey
- The lower range of this view, inclusive, or nil for unbounded.
Package visible for use by nested classes.
maxKey
final java.lang.Object maxKey
- The upper range of this view, exclusive, or nil for unbounded.
Package visible for use by nested classes.
entries
private Set entries
- The cache for
entrySet()55 .
| Constructor Detail |
TreeMap.SubMap
TreeMap.SubMap(java.lang.Object minKey, java.lang.Object maxKey)
- Create a SubMap representing the elements between minKey (inclusive)
and maxKey (exclusive). If minKey is nil, SubMap has no lower bound
(headMap). If maxKey is nil, the SubMap has no upper bound (tailMap).
| Method Detail |
keyInRange
boolean keyInRange(java.lang.Object key)
- Check if "key" is in within the range bounds for this SubMap. The
lower ("from") SubMap range is inclusive, and the upper ("to") bound
is exclusive. Package visible for use by nested classes.
clear
public void clear()
- Description copied from interface:
Map - Remove all entries from this Map (optional operation).
- Specified by:
clearin interfaceMap- Overrides:
clearin classAbstractMap
comparator
public Comparator comparator()
- Description copied from interface:
SortedMap - Returns the comparator used in sorting this map, or null if it is
the keys' natural ordering.
- Specified by:
comparatorin interfaceSortedMap
containsKey
public boolean containsKey(java.lang.Object key)
- Description copied from interface:
Map - Returns true if this contains a mapping for the given key.
- Specified by:
containsKeyin interfaceMap- Overrides:
containsKeyin classAbstractMap
containsValue
public boolean containsValue(java.lang.Object value)
- Description copied from interface:
Map - Returns true if this contains at least one mapping with the given value.
In other words, returns true if a value v exists where
(value == null ? v == null : value.equals(v)). This usually requires linear time.- Specified by:
containsValuein interfaceMap- Overrides:
containsValuein classAbstractMap
entrySet
public Set entrySet()
- Description copied from interface:
Map - Returns a set view of the mappings in this Map. Each element in the
set is a Map.Entry. The set is backed by the map, so that changes in
one show up in the other. Modifications made while an iterator is
in progress cause undefined behavior. If the set supports removal,
these methods remove the underlying mapping from the map:
Iterator.remove,Set.remove,removeAll,retainAll, andclear. Element addition, viaaddoraddAll, is not supported via this set.- Specified by:
entrySetin interfaceMap- Specified by:
entrySetin classAbstractMap
firstKey
public java.lang.Object firstKey()
- Description copied from interface:
SortedMap - Returns the first (lowest sorted) key in the map.
get
public java.lang.Object get(java.lang.Object key)
- Description copied from interface:
Map - Returns the value mapped by the given key. Returns
nullif there is no mapping. However, in Maps that accept null values, you must rely oncontainsKeyto determine if a mapping exists.- Specified by:
getin interfaceMap- Overrides:
getin classAbstractMap
headMap
public SortedMap headMap(java.lang.Object toKey)
- Description copied from interface:
SortedMap - Returns a view of the portion of the map strictly less than toKey. The
view is backed by this map, so changes in one show up in the other.
The submap supports all optional operations of the original.
The returned map throws an IllegalArgumentException any time a key is used which is out of the range of toKey. Note that the endpoint, toKey, is not included; if you want this value to be included, pass its successor object in to toKey. For example, for Integers, you could request
headMap(new Integer(limit.intValue() + 1)).
keySet
public Set keySet()
- Description copied from interface:
Map - Returns a set view of the keys in this Map. The set is backed by the
map, so that changes in one show up in the other. Modifications made
while an iterator is in progress cause undefined behavior. If the set
supports removal, these methods remove the underlying mapping from
the map:
Iterator.remove,Set.remove,removeAll,retainAll, andclear. Element addition, viaaddoraddAll, is not supported via this set.- Specified by:
keySetin interfaceMap- Overrides:
keySetin classAbstractMap
lastKey
public java.lang.Object lastKey()
- Description copied from interface:
SortedMap - Returns the last (highest sorted) key in the map.
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
- Description copied from interface:
Map - Associates the given key to the given value (optional operation). If the
map already contains the key, its value is replaced. Be aware that in
a map that permits
nullvalues, a null return does not always imply that the mapping was created.- Specified by:
putin interfaceMap- Overrides:
putin classAbstractMap
remove
public java.lang.Object remove(java.lang.Object key)
- Description copied from interface:
Map - Removes the mapping for this key if present (optional operation). If
the key is not present, this returns null. Note that maps which permit
null values may also return null if the key was removed.
- Specified by:
removein interfaceMap- Overrides:
removein classAbstractMap
size
public int size()
- Description copied from interface:
Map - Returns the number of key-value mappings in the map. If there are more
than Integer.MAX_VALUE mappings, return Integer.MAX_VALUE.
- Specified by:
sizein interfaceMap- Overrides:
sizein classAbstractMap
subMap
public SortedMap subMap(java.lang.Object fromKey, java.lang.Object toKey)
- Description copied from interface:
SortedMap - Returns a view of the portion of the map greater than or equal to
fromKey, and strictly less than toKey. The view is backed by this map,
so changes in one show up in the other. The submap supports all
optional operations of the original.
The returned map throws an IllegalArgumentException any time a key is used which is out of the range of fromKey and toKey. Note that the lower endpoint is included, but the upper is not; if you want to change the inclusion or exclusion of an endpoint, pass its successor object in instead. For example, for Integers, you could request
subMap(new Integer(lowlimit.intValue() + 1), new Integer(highlimit.intValue() + 1))to reverse the inclusiveness of both endpoints.
tailMap
public SortedMap tailMap(java.lang.Object fromKey)
- Description copied from interface:
SortedMap - Returns a view of the portion of the map greater than or equal to
fromKey. The view is backed by this map, so changes in one show up
in the other. The submap supports all optional operations of the original.
The returned map throws an IllegalArgumentException any time a key is used which is out of the range of fromKey. Note that the endpoint, fromKey, is included; if you do not want this value to be included, pass its successor object in to fromKey. For example, for Integers, you could request
tailMap(new Integer(limit.intValue() + 1)).
values
public Collection values()
- Description copied from interface:
Map - Returns a collection (or bag) view of the values in this Map. The
collection is backed by the map, so that changes in one show up in
the other. Modifications made while an iterator is in progress cause
undefined behavior. If the collection supports removal, these methods
remove the underlying mapping from the map:
Iterator.remove,Collection.remove,removeAll,retainAll, andclear. Element addition, viaaddoraddAll, is not supported via this collection.- Specified by:
valuesin interfaceMap- Overrides:
valuesin classAbstractMap
|
|||||||||
| Home >> All >> java >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC