Build 1.0_r1(from source)

java.util
Class TreeMap.SubMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.TreeMap.SubMap<K,V>
All Implemented Interfaces:
Serializable, Map<K,V>, SortedMap<K,V>
Enclosing class:
TreeMap<K,V>

static final class TreeMap.SubMap<K,V>
extends AbstractMap<K,V>
implements SortedMap<K,V>, Serializable


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
(package private)  K endKey
           
(package private)  Set<Map.Entry<K,V>> entrySet
           
(package private)  boolean hasEnd
           
(package private)  boolean hasStart
           
(package private)  K startKey
           
 
Fields inherited from class java.util.AbstractMap
keySet, valuesCollection
 
Constructor Summary
TreeMap.SubMap(K start, TreeMap<K,V> map)
           
TreeMap.SubMap(K start, TreeMap<K,V> map, K end)
           
TreeMap.SubMap(TreeMap<K,V> map, K end)
           
 
Method Summary
 Comparator<? super K> comparator()
          Returns the Comparator used to compare elements in this SortedMap.
 boolean containsKey(Object key)
          Searches this Map for the specified key.
 Set<Map.Entry<K,V>> entrySet()
          Returns a set view of the mappings contained in this map.
(package private)  TreeMap.Entry<K,V> firstEntry()
           
 K firstKey()
          Answer the first sorted key in this SortedMap.
 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 SortedMap which contains keys less than the end key.
 boolean isEmpty()
          Returns if this Map has no elements, a size of zero.
 Set<K> keySet()
          Returns a Set of the keys contained in this Map.
 K lastKey()
          Returns the last sorted key in this SortedMap.
 V put(K key, V value)
          Maps the specified key to the specified value.
 V remove(Object key)
          Removes a mapping with the specified key from this Map.
 SortedMap<K,V> subMap(K startKey, K endKey)
          Returns a SortedMap of the specified portion of this SortedMap which contains keys greater or equal to the start key but less than the end key.
 SortedMap<K,V> tailMap(K startKey)
          Returns a SortedMap of the specified portion of this SortedMap which contains keys greater or equal to the start key.
 Collection<V> values()
          Returns a collection of the values contained in this map.
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, putAll, size, toString
 
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, putAll, size
 

Field Detail

hasStart

boolean hasStart

hasEnd

boolean hasEnd

startKey

K startKey

endKey

K endKey

entrySet

transient Set<Map.Entry<K,V>> entrySet
Constructor Detail

TreeMap.SubMap

TreeMap.SubMap(K start,
               TreeMap<K,V> map)

TreeMap.SubMap

TreeMap.SubMap(K start,
               TreeMap<K,V> map,
               K end)

TreeMap.SubMap

TreeMap.SubMap(TreeMap<K,V> map,
               K end)
Method Detail

comparator

public Comparator<? super K> comparator()
Description copied from interface: SortedMap
Returns the Comparator used to compare elements in this SortedMap.

Specified by:
comparator in interface SortedMap<K,V>
Returns:
a Comparator or null if the natural order is used

containsKey

public boolean containsKey(Object key)
Description copied from class: AbstractMap
Searches this Map for the specified key.

Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractMap<K,V>
Parameters:
key - the object to search for
Returns:
true if key is a key of this Map, false otherwise

entrySet

public Set<Map.Entry<K,V>> entrySet()
Description copied from class: AbstractMap
Returns a set view of the mappings contained in this map. Each element in this set is a Map.Entry. The set is backed by the map so changes to one are reflected by the other. (If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined.) The set supports remove, removeAll, retainAll and clear operations, and it does not support add or addAll operations.

Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>
Returns:
a set of the mappings contained in this map

firstKey

public K firstKey()
Description copied from interface: SortedMap
Answer the first sorted key in this SortedMap.

Specified by:
firstKey in interface SortedMap<K,V>
Returns:
the first sorted key

firstEntry

TreeMap.Entry<K,V> firstEntry()

get

public V get(Object key)
Description copied from class: AbstractMap
Returns the value of the mapping with the specified key.

Specified by:
get in interface Map<K,V>
Overrides:
get in class AbstractMap<K,V>
Parameters:
key - the key
Returns:
the value of the mapping with the specified key

headMap

public SortedMap<K,V> headMap(K endKey)
Description copied from interface: SortedMap
Returns a SortedMap of the specified portion of this SortedMap which contains keys less than the end key. Users should be aware that the return value is actually backed by this SortedMap. Hence any modifications made to one will be immediately visible to the other.

Specified by:
headMap in interface SortedMap<K,V>
Parameters:
endKey - the end key
Returns:
a submap where the keys are less than endKey

isEmpty

public boolean isEmpty()
Description copied from class: AbstractMap
Returns if this Map has no elements, a size of zero.

Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in class AbstractMap<K,V>
Returns:
true if this Map has no elements, false otherwise
See Also:
AbstractMap.size()

keySet

public Set<K> keySet()
Description copied from class: AbstractMap
Returns a Set of the keys contained in this Map. The set is backed by this Map so changes to one are reflected by the other. The set does not support adding.

Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class AbstractMap<K,V>
Returns:
a Set of the keys

lastKey

public K lastKey()
Description copied from interface: SortedMap
Returns the last sorted key in this SortedMap.

Specified by:
lastKey in interface SortedMap<K,V>
Returns:
the last sorted key

put

public V put(K key,
             V value)
Description copied from class: AbstractMap
Maps the specified key to the specified value.

Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>
Parameters:
key - the key
value - the value
Returns:
the value of any previous mapping with the specified key or null if there was no mapping

remove

public V remove(Object key)
Description copied from class: AbstractMap
Removes a mapping with the specified key from this Map.

Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMap<K,V>
Parameters:
key - the key of the mapping to remove
Returns:
the value of the removed mapping or null if key is not a key in this Map

subMap

public SortedMap<K,V> subMap(K startKey,
                             K endKey)
Description copied from interface: SortedMap
Returns a SortedMap of the specified portion of this SortedMap which contains keys greater or equal to the start key but less than the end key. Users should be aware that the return value is actually backed by this SortedMap. Hence any modifications made to one will be immediately visible to the other.

Specified by:
subMap in interface SortedMap<K,V>
Parameters:
startKey - the start key
endKey - the end key
Returns:
a submap where the keys are greater or equal to startKey and less than endKey

tailMap

public SortedMap<K,V> tailMap(K startKey)
Description copied from interface: SortedMap
Returns a SortedMap of the specified portion of this SortedMap which contains keys greater or equal to the start key. The returned SortedMap is backed by this SortedMap so changes to one are reflected by the other.

Specified by:
tailMap in interface SortedMap<K,V>
Parameters:
startKey - the start key
Returns:
a submap where the keys are greater or equal to startKey

values

public Collection<V> values()
Description copied from class: AbstractMap
Returns a collection of the values contained in this map. The collection is backed by this map so changes to one are reflected by the other. The collection supports remove, removeAll, retainAll and clear operations, and it does not support add or addAll operations. This method returns a collection which is the subclass of AbstractCollection. The iterator method of this subclass returns a "wrapper object" over the iterator of map's entrySet(). The size method wraps the map's size method and the contains method wraps the map's containsValue method. The collection is created when this method is called at first time and returned in response to all subsequent calls. This method may return different Collection when multiple calls to this method, since it has no synchronization performed.

Specified by:
values in interface Map<K,V>
Overrides:
values in class AbstractMap<K,V>
Returns:
a collection of the values contained in this map

Build 1.0_r1(from source)

Please submit a feedback, bug or feature