net.sf.beanlib.utils.range
Class ExtensibleTreeMap.SubMap

java.lang.Object
  extended by net.sf.beanlib.utils.range.AbstractMap<K,V>
      extended by net.sf.beanlib.utils.range.ExtensibleTreeMap.SubMap
All Implemented Interfaces:
Serializable, Map<K,V>, SortedMap<K,V>
Enclosing class:
ExtensibleTreeMap<K,V>

private class ExtensibleTreeMap.SubMap
extends AbstractMap<K,V>
implements SortedMap<K,V>, Serializable


Nested Class Summary
private  class ExtensibleTreeMap.SubMap.EntrySetView
           
 
Nested classes/interfaces inherited from class net.sf.beanlib.utils.range.AbstractMap
AbstractMap.SimpleEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
private  Set<Map.Entry<K,V>> entrySet
           
private  K 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  K toKey
           
 
Fields inherited from class net.sf.beanlib.utils.range.AbstractMap
keySet, values
 
Constructor Summary
ExtensibleTreeMap.SubMap(boolean fromStart, K fromKey, boolean toEnd, K toKey)
           
ExtensibleTreeMap.SubMap(K key, boolean headMap)
           
ExtensibleTreeMap.SubMap(K fromKey, K toKey)
           
 
Method Summary
 Comparator<? super K> comparator()
           
 boolean containsKey(Object key)
          Returns true if this map contains a mapping for the specified key.
 Set<Map.Entry<K,V>> entrySet()
          Returns a set view of the mappings contained in this map.
 K firstKey()
           
 V get(Object key)
          Returns the value to which this map maps the specified key.
 SortedMap<K,V> headMap(K toKey)
           
private  boolean inRange(K key)
           
private  boolean inRange2(K key)
           
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
 K lastKey()
           
 V put(K key, V value)
          Associates the specified value with the specified key in this map (optional operation).
 SortedMap<K,V> subMap(K fromKey, K toKey)
           
 SortedMap<K,V> tailMap(K fromKey)
           
 
Methods inherited from class net.sf.beanlib.utils.range.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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

fromStart

private boolean fromStart
fromKey is significant only if fromStart is false. Similarly, toKey is significant only if toStart is false.


toEnd

private boolean toEnd
fromKey is significant only if fromStart is false. Similarly, toKey is significant only if toStart is false.


fromKey

private K fromKey

toKey

private K toKey

entrySet

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

ExtensibleTreeMap.SubMap

ExtensibleTreeMap.SubMap(K fromKey,
                         K toKey)

ExtensibleTreeMap.SubMap

ExtensibleTreeMap.SubMap(K key,
                         boolean headMap)

ExtensibleTreeMap.SubMap

ExtensibleTreeMap.SubMap(boolean fromStart,
                         K fromKey,
                         boolean toEnd,
                         K toKey)
Method Detail

isEmpty

public boolean isEmpty()
Description copied from class: AbstractMap
Returns true if this map contains no key-value mappings.

This implementation returns size() == 0.

Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in class AbstractMap<K,V>
Returns:
true if this map contains no key-value mappings.

containsKey

public boolean containsKey(Object key)
Description copied from class: AbstractMap
Returns true if this map contains a mapping for the specified key.

This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, true is returned. If the iteration terminates without finding such an entry, false is returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.

Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractMap<K,V>
Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.

get

public V get(Object key)
Description copied from class: AbstractMap
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, the entry's value is returned. If the iteration terminates without finding such an entry, null is returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.

Specified by:
get in interface Map<K,V>
Overrides:
get in class AbstractMap<K,V>
Parameters:
key - key whose associated value is to be returned.
Returns:
the value to which this map maps the specified key.
See Also:
AbstractMap.containsKey(Object)

put

public V put(K key,
             V value)
Description copied from class: AbstractMap
Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for this key, the old value is replaced.

This implementation always throws an UnsupportedOperationException.

Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.)

comparator

public Comparator<? super K> comparator()
Specified by:
comparator in interface SortedMap<K,V>

firstKey

public K firstKey()
Specified by:
firstKey in interface SortedMap<K,V>

lastKey

public K lastKey()
Specified by:
lastKey in interface SortedMap<K,V>

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 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 entry from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

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

subMap

public SortedMap<K,V> subMap(K fromKey,
                             K toKey)
Specified by:
subMap in interface SortedMap<K,V>

headMap

public SortedMap<K,V> headMap(K toKey)
Specified by:
headMap in interface SortedMap<K,V>

tailMap

public SortedMap<K,V> tailMap(K fromKey)
Specified by:
tailMap in interface SortedMap<K,V>

inRange

private boolean inRange(K key)

inRange2

private boolean inRange2(K key)