|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.beanlib.util.AbstractMap<K,V> net.sf.beanlib.util.concurrent.ConcurrentSkipListMap.SubMap<K,V>
static final class ConcurrentSkipListMap.SubMap<K,V>
Submaps returned by ConcurrentSkipListMap
submap operations
represent a subrange of mappings of their underlying
maps. Instances of this class support all methods of their
underlying maps, differing in that mappings outside their range are
ignored, and attempts to add mappings outside their ranges result
in IllegalArgumentException
. Instances of this class are
constructed only using the subMap, headMap, and
tailMap methods of their underlying maps.
Nested Class Summary | |
---|---|
(package private) class |
ConcurrentSkipListMap.SubMap.SubMapEntryIterator
|
(package private) class |
ConcurrentSkipListMap.SubMap.SubMapIter<T>
Variant of main Iter class to traverse through submaps. |
(package private) class |
ConcurrentSkipListMap.SubMap.SubMapKeyIterator
|
(package private) class |
ConcurrentSkipListMap.SubMap.SubMapValueIterator
|
Nested classes/interfaces inherited from class net.sf.beanlib.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Field Summary | |
---|---|
private Set<Map.Entry<K,V>> |
entrySetView
|
private K |
hi
upper bound key, or null if to end |
private boolean |
hiInclusive
inclusion flag for hi |
private boolean |
isDescending
direction |
private ConcurrentSkipListMap.KeySet<K> |
keySetView
|
private K |
lo
lower bound key, or null if from start |
private boolean |
loInclusive
inclusion flag for lo |
private ConcurrentSkipListMap<K,V> |
m
Underlying map |
private static long |
serialVersionUID
|
private Collection<V> |
valuesView
|
Constructor Summary | |
---|---|
ConcurrentSkipListMap.SubMap(ConcurrentSkipListMap<K,V> map,
K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive,
boolean isDescending)
Creates a new submap, initializing all fields |
Method Summary | |
---|---|
Map.Entry<K,V> |
ceilingEntry(K key)
Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if
there is no such key. |
K |
ceilingKey(K key)
Returns the least key greater than or equal to the given key, or null if there is no such key. |
private void |
checkKeyBounds(K key)
|
void |
clear()
|
Comparator<? super K> |
comparator()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
NavigableSet<K> |
descendingKeySet()
Returns a reverse order NavigableSet view of the keys contained in this map. |
ConcurrentSkipListMap.SubMap<K,V> |
descendingMap()
Returns a reverse order view of the mappings contained in this map. |
(package private) Iterator<Map.Entry<K,V>> |
entryIterator()
|
Set<Map.Entry<K,V>> |
entrySet()
|
Map.Entry<K,V> |
firstEntry()
Returns a key-value mapping associated with the least key in this map, or null if the map is empty. |
K |
firstKey()
|
Map.Entry<K,V> |
floorEntry(K key)
Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there
is no such key. |
K |
floorKey(K key)
Returns the greatest key less than or equal to the given key, or null if there is no such key. |
V |
get(Object key)
|
private Map.Entry<K,V> |
getNearEntry(K key,
int rel)
Submap version of ConcurrentSkipListMap.getNearEntry |
private K |
getNearKey(K key,
int rel)
|
ConcurrentSkipListMap.SubMap<K,V> |
headMap(K toKey)
|
ConcurrentSkipListMap.SubMap<K,V> |
headMap(K toKey,
boolean inclusive)
Returns a view of the portion of this map whose keys are less than (or equal to, if inclusive is true) toKey . |
Map.Entry<K,V> |
higherEntry(K key)
Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there
is no such key. |
K |
higherKey(K key)
Returns the least key strictly greater than the given key, or null if there is no such key. |
private Map.Entry<K,V> |
highestEntry()
|
private K |
highestKey()
Returns highest absolute key (ignoring directonality) |
private ConcurrentSkipListMap.Node<K,V> |
hiNode()
Returns highest node. |
private boolean |
inBounds(K key)
|
private boolean |
isBeforeEnd(ConcurrentSkipListMap.Node<K,V> n)
Returns true if node key is less than upper bound of range |
boolean |
isEmpty()
|
(package private) Iterator<K> |
keyIterator()
|
NavigableSet<K> |
keySet()
|
Map.Entry<K,V> |
lastEntry()
Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty. |
K |
lastKey()
|
private ConcurrentSkipListMap.Node<K,V> |
loNode()
Returns lowest node. |
Map.Entry<K,V> |
lowerEntry(K key)
Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is
no such key. |
K |
lowerKey(K key)
Returns the greatest key strictly less than the given key, or null if there is no such key. |
private Map.Entry<K,V> |
lowestEntry()
|
private K |
lowestKey()
Returns lowest absolute key (ignoring directonality) |
NavigableSet<K> |
navigableKeySet()
Returns a NavigableSet view of the keys contained in this map. |
private ConcurrentSkipListMap.SubMap<K,V> |
newSubMap(K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive)
Utility to create submaps, where given bounds override unbounded(null) ones and/or are checked against bounded ones. |
Map.Entry<K,V> |
pollFirstEntry()
Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty. |
Map.Entry<K,V> |
pollLastEntry()
Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty. |
V |
put(K key,
V value)
|
V |
putIfAbsent(K key,
V value)
|
V |
remove(Object key)
|
boolean |
remove(Object key,
Object value)
|
private Map.Entry<K,V> |
removeHighest()
|
private Map.Entry<K,V> |
removeLowest()
|
V |
replace(K key,
V value)
|
boolean |
replace(K key,
V oldValue,
V newValue)
|
int |
size()
|
ConcurrentSkipListMap.SubMap<K,V> |
subMap(K fromKey,
boolean fromInclusive,
K toKey,
boolean toInclusive)
Returns a view of the portion of this map whose keys range from fromKey to toKey . |
ConcurrentSkipListMap.SubMap<K,V> |
subMap(K fromKey,
K toKey)
|
ConcurrentSkipListMap.SubMap<K,V> |
tailMap(K fromKey)
|
ConcurrentSkipListMap.SubMap<K,V> |
tailMap(K fromKey,
boolean inclusive)
Returns a view of the portion of this map whose keys are greater than (or equal to, if inclusive is true) fromKey . |
private boolean |
tooHigh(K key)
|
private boolean |
tooLow(K key)
|
(package private) Iterator<V> |
valueIterator()
|
Collection<V> |
values()
|
Methods inherited from class net.sf.beanlib.util.AbstractMap |
---|
clone, equals, hashCode, putAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private final ConcurrentSkipListMap<K,V> m
private final K lo
private final K hi
private final boolean loInclusive
private final boolean hiInclusive
private final boolean isDescending
private transient ConcurrentSkipListMap.KeySet<K> keySetView
private transient Set<Map.Entry<K,V>> entrySetView
private transient Collection<V> valuesView
Constructor Detail |
---|
ConcurrentSkipListMap.SubMap(ConcurrentSkipListMap<K,V> map, K fromKey, boolean fromInclusive, K toKey, boolean toInclusive, boolean isDescending)
Method Detail |
---|
private boolean tooLow(K key)
private boolean tooHigh(K key)
private boolean inBounds(K key)
private void checkKeyBounds(K key) throws IllegalArgumentException
IllegalArgumentException
private boolean isBeforeEnd(ConcurrentSkipListMap.Node<K,V> n)
private ConcurrentSkipListMap.Node<K,V> loNode()
private ConcurrentSkipListMap.Node<K,V> hiNode()
private K lowestKey()
private K highestKey()
private Map.Entry<K,V> lowestEntry()
private Map.Entry<K,V> highestEntry()
private Map.Entry<K,V> removeLowest()
private Map.Entry<K,V> removeHighest()
private Map.Entry<K,V> getNearEntry(K key, int rel)
private K getNearKey(K key, int rel)
public boolean containsKey(Object key)
AbstractMap
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.
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
public V get(Object key)
AbstractMap
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.
get
in interface Map<K,V>
get
in class AbstractMap<K,V>
public V put(K key, V value)
AbstractMap
This implementation always throws an UnsupportedOperationException.
put
in interface Map<K,V>
put
in class AbstractMap<K,V>
public V remove(Object key)
AbstractMap
This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, its value is obtained with its getValue operation, the entry is removed from the collection (and the backing map) with the iterator's remove operation, and the saved 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.
Note that this implementation throws an UnsupportedOperationException if the entrySet iterator does not support the remove method and this map contains a mapping for the specified key.
remove
in interface Map<K,V>
remove
in class AbstractMap<K,V>
public int size()
AbstractMap
This implementation returns entrySet().size().
size
in interface Map<K,V>
size
in class AbstractMap<K,V>
public boolean isEmpty()
AbstractMap
This implementation returns size() == 0.
isEmpty
in interface Map<K,V>
isEmpty
in class AbstractMap<K,V>
public boolean containsValue(Object value)
AbstractMap
This implementation iterates over entrySet() searching for an entry with the specified value. 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.
containsValue
in interface Map<K,V>
containsValue
in class AbstractMap<K,V>
public void clear()
AbstractMap
This implementation calls entrySet().clear().
Note that this implementation throws an UnsupportedOperationException if the entrySet does not support the clear operation.
clear
in interface Map<K,V>
clear
in class AbstractMap<K,V>
public V putIfAbsent(K key, V value)
putIfAbsent
in interface ConcurrentMap<K,V>
public boolean remove(Object key, Object value)
remove
in interface ConcurrentMap<K,V>
public boolean replace(K key, V oldValue, V newValue)
replace
in interface ConcurrentMap<K,V>
public V replace(K key, V value)
replace
in interface ConcurrentMap<K,V>
public Comparator<? super K> comparator()
comparator
in interface SortedMap<K,V>
private ConcurrentSkipListMap.SubMap<K,V> newSubMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
public ConcurrentSkipListMap.SubMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
NavigableMap
fromKey
to toKey
. If fromKey
and
toKey
are equal, the returned map is empty unless
fromExclusive
and toExclusive
are both true. The
returned map is backed by this map, so changes in the returned map are
reflected in this map, and vice-versa. The returned map supports all
optional map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside of its range, or to construct a
submap either of whose endpoints lie outside its range.
subMap
in interface ConcurrentNavigableMap<K,V>
subMap
in interface NavigableMap<K,V>
fromKey
- low endpoint of the keys in the returned mapfromInclusive
- true
if the low endpoint
is to be included in the returned viewtoKey
- high endpoint of the keys in the returned maptoInclusive
- true
if the high endpoint
is to be included in the returned view
fromKey
to toKey
public ConcurrentSkipListMap.SubMap<K,V> headMap(K toKey, boolean inclusive)
NavigableMap
inclusive
is true) toKey
. The returned
map is backed by this map, so changes in the returned map are reflected
in this map, and vice-versa. The returned map supports all optional
map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside its range.
headMap
in interface ConcurrentNavigableMap<K,V>
headMap
in interface NavigableMap<K,V>
toKey
- high endpoint of the keys in the returned mapinclusive
- true
if the high endpoint
is to be included in the returned view
inclusive
is true) toKey
public ConcurrentSkipListMap.SubMap<K,V> tailMap(K fromKey, boolean inclusive)
NavigableMap
inclusive
is true) fromKey
. The returned
map is backed by this map, so changes in the returned map are reflected
in this map, and vice-versa. The returned map supports all optional
map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside its range.
tailMap
in interface ConcurrentNavigableMap<K,V>
tailMap
in interface NavigableMap<K,V>
fromKey
- low endpoint of the keys in the returned mapinclusive
- true
if the low endpoint
is to be included in the returned view
inclusive
is true) fromKey
public ConcurrentSkipListMap.SubMap<K,V> subMap(K fromKey, K toKey)
NavigableMap
Equivalent to subMap(fromKey, true, toKey, false)
.
subMap
in interface SortedMap<K,V>
subMap
in interface ConcurrentNavigableMap<K,V>
subMap
in interface NavigableMap<K,V>
public ConcurrentSkipListMap.SubMap<K,V> headMap(K toKey)
NavigableMap
Equivalent to headMap(toKey, false)
.
headMap
in interface SortedMap<K,V>
headMap
in interface ConcurrentNavigableMap<K,V>
headMap
in interface NavigableMap<K,V>
public ConcurrentSkipListMap.SubMap<K,V> tailMap(K fromKey)
NavigableMap
Equivalent to tailMap(fromKey, true)
.
tailMap
in interface SortedMap<K,V>
tailMap
in interface ConcurrentNavigableMap<K,V>
tailMap
in interface NavigableMap<K,V>
public ConcurrentSkipListMap.SubMap<K,V> descendingMap()
ConcurrentNavigableMap
The returned map has an ordering equivalent to
Collections.reverseOrder
(comparator()).
The expression m.descendingMap().descendingMap()
returns a
view of m
essentially equivalent to m
.
descendingMap
in interface ConcurrentNavigableMap<K,V>
descendingMap
in interface NavigableMap<K,V>
public Map.Entry<K,V> ceilingEntry(K key)
NavigableMap
null
if
there is no such key.
ceilingEntry
in interface NavigableMap<K,V>
key
- the key
key
, or null
if there is no such keypublic K ceilingKey(K key)
NavigableMap
null
if there is no such key.
ceilingKey
in interface NavigableMap<K,V>
key
- the key
key
,
or null
if there is no such keypublic Map.Entry<K,V> lowerEntry(K key)
NavigableMap
null
if there is
no such key.
lowerEntry
in interface NavigableMap<K,V>
key
- the key
key
,
or null
if there is no such keypublic K lowerKey(K key)
NavigableMap
null
if there is no such key.
lowerKey
in interface NavigableMap<K,V>
key
- the key
key
,
or null
if there is no such keypublic Map.Entry<K,V> floorEntry(K key)
NavigableMap
null
if there
is no such key.
floorEntry
in interface NavigableMap<K,V>
key
- the key
key
, or null
if there is no such keypublic K floorKey(K key)
NavigableMap
null
if there is no such key.
floorKey
in interface NavigableMap<K,V>
key
- the key
key
,
or null
if there is no such keypublic Map.Entry<K,V> higherEntry(K key)
NavigableMap
null
if there
is no such key.
higherEntry
in interface NavigableMap<K,V>
key
- the key
key
,
or null
if there is no such keypublic K higherKey(K key)
NavigableMap
null
if there is no such key.
higherKey
in interface NavigableMap<K,V>
key
- the key
key
,
or null
if there is no such keypublic K firstKey()
firstKey
in interface SortedMap<K,V>
public K lastKey()
lastKey
in interface SortedMap<K,V>
public Map.Entry<K,V> firstEntry()
NavigableMap
null
if the map is empty.
firstEntry
in interface NavigableMap<K,V>
null
if this map is emptypublic Map.Entry<K,V> lastEntry()
NavigableMap
null
if the map is empty.
lastEntry
in interface NavigableMap<K,V>
null
if this map is emptypublic Map.Entry<K,V> pollFirstEntry()
NavigableMap
null
if the map is empty.
pollFirstEntry
in interface NavigableMap<K,V>
null
if this map is emptypublic Map.Entry<K,V> pollLastEntry()
NavigableMap
null
if the map is empty.
pollLastEntry
in interface NavigableMap<K,V>
null
if this map is emptypublic NavigableSet<K> keySet()
AbstractMap
This implementation returns a set that subclasses AbstractSet
.
The subclass's iterator method returns a "wrapper object" over this
map's entrySet() iterator. The size method
delegates to this map's size method and the
contains method delegates to this map's
containsKey method.
The set is created the first time this method is called, and returned in response to all subsequent calls. No synchronization is performed, so there is a slight chance that multiple calls to this method will not all return the same set.
keySet
in interface Map<K,V>
keySet
in interface ConcurrentNavigableMap<K,V>
keySet
in class AbstractMap<K,V>
public NavigableSet<K> navigableKeySet()
ConcurrentNavigableMap
NavigableSet
view of the keys contained in this map.
The set's iterator returns the keys in ascending order.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. 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.
The view's iterator
is a "weakly consistent" iterator
that will never throw ConcurrentModificationException
,
and guarantees to traverse elements as they existed upon
construction of the iterator, and may (but is not guaranteed to)
reflect any modifications subsequent to construction.
navigableKeySet
in interface ConcurrentNavigableMap<K,V>
navigableKeySet
in interface NavigableMap<K,V>
public Collection<V> values()
AbstractMap
This implementation returns a collection that subclasses AbstractCollection
. The subclass's iterator method returns a
"wrapper object" over this map's entrySet() iterator.
The size method delegates to this map's size
method and the contains method delegates to this map's
containsValue method.
The collection is created the first time this method is called, and returned in response to all subsequent calls. No synchronization is performed, so there is a slight chance that multiple calls to this method will not all return the same collection.
values
in interface Map<K,V>
values
in class AbstractMap<K,V>
public Set<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
entrySet
in class AbstractMap<K,V>
public NavigableSet<K> descendingKeySet()
ConcurrentNavigableMap
NavigableSet
view of the keys contained in this map.
The set's iterator returns the keys in descending order.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. 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.
The view's iterator
is a "weakly consistent" iterator
that will never throw ConcurrentModificationException
,
and guarantees to traverse elements as they existed upon
construction of the iterator, and may (but is not guaranteed to)
reflect any modifications subsequent to construction.
descendingKeySet
in interface ConcurrentNavigableMap<K,V>
descendingKeySet
in interface NavigableMap<K,V>
Iterator<K> keyIterator()
Iterator<V> valueIterator()
Iterator<Map.Entry<K,V>> entryIterator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |