|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap java.util.TreeMap.SubMap
Nested Class Summary | |
private class |
TreeMap.SubMap.EntrySetView
|
Nested classes inherited from class java.util.AbstractMap |
AbstractMap.SimpleEntry |
Nested classes inherited from class java.util.Map |
Map.Entry |
Field Summary | |
private Set |
entrySet
|
private Object |
fromKey
|
private boolean |
fromStart
fromKey is significant only if fromStart is false. |
private static long |
serialVersionUID
|
private boolean |
toEnd
fromKey is significant only if fromStart is false. |
private Object |
toKey
|
Fields inherited from class java.util.AbstractMap |
keySet, values |
Constructor Summary | |
(package private) |
TreeMap.SubMap(boolean fromStart,
Object fromKey,
boolean toEnd,
Object toKey)
|
(package private) |
TreeMap.SubMap(Object key,
boolean headMap)
|
(package private) |
TreeMap.SubMap(Object fromKey,
Object toKey)
|
Method Summary | |
Comparator |
comparator()
Returns the comparator associated with this sorted map, or null if it uses its keys' natural ordering. |
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified key. |
Set |
entrySet()
Returns a set view of the mappings contained in this map. |
Object |
firstKey()
Returns the first (lowest) key currently in this sorted map. |
Object |
get(Object key)
Returns the value to which this map maps the specified key. |
SortedMap |
headMap(Object toKey)
Returns a view of the portion of this sorted map whose keys are strictly less than toKey. |
private boolean |
inRange(Object key)
|
private boolean |
inRange2(Object key)
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
Object |
lastKey()
Returns the last (highest) key currently in this sorted map. |
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this map (optional operation). |
SortedMap |
subMap(Object fromKey,
Object toKey)
Returns a view of the portion of this sorted map whose keys range from fromKey, inclusive, to toKey, exclusive. |
SortedMap |
tailMap(Object fromKey)
Returns a view of the portion of this sorted map whose keys are greater than or equal to fromKey. |
Methods inherited from class java.util.AbstractMap |
clear, clone, containsValue, equals, hashCode, keySet, putAll, remove, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
clear, containsValue, equals, hashCode, keySet, putAll, remove, size, values |
Field Detail |
private static final long serialVersionUID
private boolean fromStart
private boolean toEnd
private Object fromKey
private Object toKey
private transient Set entrySet
Constructor Detail |
TreeMap.SubMap(Object fromKey, Object toKey)
TreeMap.SubMap(Object key, boolean headMap)
TreeMap.SubMap(boolean fromStart, Object fromKey, boolean toEnd, Object toKey)
Method Detail |
public boolean isEmpty()
Map
isEmpty
in interface Map
isEmpty
in class AbstractMap
public boolean containsKey(Object key)
Map
containsKey
in interface Map
containsKey
in class AbstractMap
key
- key whose presence in this map is to be tested.
public Object get(Object key)
Map
More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)
get
in interface Map
get
in class AbstractMap
key
- key whose associated value is to be returned.
AbstractMap.containsKey(Object)
public Object put(Object key, Object value)
Map
m.containsKey(k)
would return
true.))
put
in interface Map
put
in class AbstractMap
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
public Comparator comparator()
SortedMap
comparator
in interface SortedMap
public Object firstKey()
SortedMap
firstKey
in interface SortedMap
public Object lastKey()
SortedMap
lastKey
in interface SortedMap
public Set entrySet()
Map
Map.Entry
. 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,
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.
entrySet
in interface Map
entrySet
in class AbstractMap
public SortedMap subMap(Object fromKey, Object toKey)
SortedMap
The map returned by this method will throw an IllegalArgumentException if the user attempts to insert a key outside the specified range.
Note: this method always returns a half-open range (which includes its low endpoint but not its high endpoint). If you need a closed range (which includes both endpoints), and the key type allows for calculation of the successor a given key, merely request the subrange from lowEndpoint to successor(highEndpoint). For example, suppose that m is a map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in m whose keys are between low and high, inclusive:
Map sub = m.subMap(low, high+"\0");A similarly technique can be used to generate an open range (which contains neither endpoint). The following idiom obtains a view containing all of the key-value mappings in m whose keys are between low and high, exclusive:
Map sub = m.subMap(low+"\0", high);
subMap
in interface SortedMap
fromKey
- low endpoint (inclusive) of the subMap.toKey
- high endpoint (exclusive) of the subMap.
public SortedMap headMap(Object toKey)
SortedMap
The map returned by this method will throw an IllegalArgumentException if the user attempts to insert a key outside the specified range.
Note: this method always returns a view that does not contain its (high) endpoint. If you need a view that does contain this endpoint, and the key type allows for calculation of the successor a given key, merely request a headMap bounded by successor(highEndpoint). For example, suppose that suppose that m is a map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in m whose keys are less than or equal to high:
Map head = m.headMap(high+"\0");
headMap
in interface SortedMap
toKey
- high endpoint (exclusive) of the subMap.
public SortedMap tailMap(Object fromKey)
SortedMap
The map returned by this method will throw an IllegalArgumentException if the user attempts to insert a key outside the specified range.
Note: this method always returns a view that contains its (low) endpoint. If you need a view that does not contain this endpoint, and the element type allows for calculation of the successor a given value, merely request a tailMap bounded by successor(lowEndpoint). For example, suppose that suppose that m is a map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in m whose keys are strictly greater than low:
Map tail = m.tailMap(low+"\0");
tailMap
in interface SortedMap
fromKey
- low endpoint (inclusive) of the tailMap.
private boolean inRange(Object key)
private boolean inRange2(Object key)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |