Package org.jboss.util.collection
Class ConcurrentSkipListMap.ConcurrentSkipListSubMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.jboss.util.collection.ConcurrentSkipListMap.ConcurrentSkipListSubMap<K,V>
-
- All Implemented Interfaces:
java.io.Serializable,java.util.concurrent.ConcurrentMap<K,V>,java.util.Map<K,V>,java.util.SortedMap<K,V>,ConcurrentNavigableMap<K,V>,NavigableMap<K,V>
- Enclosing class:
- ConcurrentSkipListMap<K,V>
static class ConcurrentSkipListMap.ConcurrentSkipListSubMap<K,V> extends java.util.AbstractMap<K,V> implements ConcurrentNavigableMap<K,V>, java.io.Serializable
Submaps returned byConcurrentSkipListMapsubmap 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 inIllegalArgumentException. Instances of this class are constructed only using the subMap, headMap, and tailMap methods of their underlying maps.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classConcurrentSkipListMap.ConcurrentSkipListSubMap.DescendingEntrySetView(package private) classConcurrentSkipListMap.ConcurrentSkipListSubMap.DescendingKeySetView(package private) classConcurrentSkipListMap.ConcurrentSkipListSubMap.EntrySetView(package private) classConcurrentSkipListMap.ConcurrentSkipListSubMap.KeySetView(package private) classConcurrentSkipListMap.ConcurrentSkipListSubMap.ValuesView
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.util.Map.Entry<K,V>>descendingEntrySetViewprivate java.util.Set<K>descendingKeySetViewprivate java.util.Set<java.util.Map.Entry<K,V>>entrySetViewprivate Kfenceupper fence key, or null if to endprivate java.util.Set<K>keySetViewprivate Kleastlower bound key, or null if from startprivate ConcurrentSkipListMap<K,V>mUnderlying mapprivate static longserialVersionUIDprivate java.util.Collection<V>valuesView
-
Constructor Summary
Constructors Constructor Description ConcurrentSkipListSubMap(ConcurrentSkipListMap<K,V> map, K least, K fence)Creates a new submap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.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 entry.KceilingKey(K key)Returns least key greater than or equal to the given key, or null if there is no such key.(package private) voidcheckKey(K key)voidclear()java.util.Comparator<? super K>comparator()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)java.util.Set<java.util.Map.Entry<K,V>>descendingEntrySet()Returns a set view of the mappings contained in this map, in descending key order.java.util.Set<K>descendingKeySet()Returns a set view of the keys contained in this map, in descending key order.java.util.Set<java.util.Map.Entry<K,V>>entrySet()java.util.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.KfirstKey()(package private) ConcurrentSkipListMap.Node<K,V>firstNode()java.util.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 entry.KfloorKey(K key)Returns the greatest key less than or equal to the given key, or null if there is no such key.Vget(java.lang.Object key)(package private) KgetFence()Returns fence key.(package private) KgetLeast()Returns least key.(package private) ConcurrentSkipListMap<K,V>getMap()Returns underlying map.ConcurrentNavigableMap<K,V>headMap(K toKey)Returns a view of the portion of this map whose keys are strictly less than toKey.java.util.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 entry.KhigherKey(K key)Returns the least key strictly greater than the given key, or null if there is no such key.(package private) booleaninHalfOpenRange(K key)(package private) booleaninOpenRange(K key)(package private) booleanisBeforeEnd(ConcurrentSkipListMap.Node<K,V> n)booleanisEmpty()java.util.Set<K>keySet()java.util.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.KlastKey()(package private) ConcurrentSkipListMap.Node<K,V>lastNode()java.util.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 entry.KlowerKey(K key)Returns the greatest key strictly less than the given key, or null if there is no such key.java.util.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.java.util.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.Vput(K key, V value)VputIfAbsent(K key, V value)Vremove(java.lang.Object key)booleanremove(java.lang.Object key, java.lang.Object value)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)intsize()ConcurrentNavigableMap<K,V>subMap(K fromKey, K toKey)Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.ConcurrentNavigableMap<K,V>tailMap(K fromKey)Returns a view of the portion of this map whose keys are greater than or equal to fromKey.java.util.Collection<V>values()-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
m
private final ConcurrentSkipListMap<K,V> m
Underlying map
-
least
private final K least
lower bound key, or null if from start
-
fence
private final K fence
upper fence key, or null if to end
-
keySetView
private transient java.util.Set<K> keySetView
-
valuesView
private transient java.util.Collection<V> valuesView
-
descendingKeySetView
private transient java.util.Set<K> descendingKeySetView
-
-
Constructor Detail
-
ConcurrentSkipListSubMap
ConcurrentSkipListSubMap(ConcurrentSkipListMap<K,V> map, K least, K fence)
Creates a new submap.- Parameters:
least- inclusive least value, or null if from startfence- exclusive upper bound or null if to end- Throws:
java.lang.IllegalArgumentException- if least and fence nonnull and least greater than fence
-
-
Method Detail
-
inHalfOpenRange
boolean inHalfOpenRange(K key)
-
inOpenRange
boolean inOpenRange(K key)
-
firstNode
ConcurrentSkipListMap.Node<K,V> firstNode()
-
lastNode
ConcurrentSkipListMap.Node<K,V> lastNode()
-
isBeforeEnd
boolean isBeforeEnd(ConcurrentSkipListMap.Node<K,V> n)
-
checkKey
void checkKey(K key) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
getMap
ConcurrentSkipListMap<K,V> getMap()
Returns underlying map. Needed by ConcurrentSkipListSet- Returns:
- the backing map
-
getLeast
K getLeast()
Returns least key. Needed by ConcurrentSkipListSet- Returns:
- least key or null if from start
-
getFence
K getFence()
Returns fence key. Needed by ConcurrentSkipListSet- Returns:
- fence key or null of to end
-
containsKey
public boolean containsKey(java.lang.Object key)
-
get
public V get(java.lang.Object key)
-
remove
public V remove(java.lang.Object key)
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
containsValue
public boolean containsValue(java.lang.Object value)
-
clear
public void clear()
-
remove
public boolean remove(java.lang.Object key, java.lang.Object value)
-
comparator
public java.util.Comparator<? super K> comparator()
-
subMap
public ConcurrentNavigableMap<K,V> subMap(K fromKey, K toKey)
Description copied from interface:ConcurrentNavigableMapReturns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal, the returned sorted map is empty.) The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa.- Specified by:
subMapin interfaceConcurrentNavigableMap<K,V>- Specified by:
subMapin interfaceNavigableMap<K,V>- Specified by:
subMapin interfacejava.util.SortedMap<K,V>- Parameters:
fromKey- low endpoint (inclusive) of the subMap.toKey- high endpoint (exclusive) of the subMap.- Returns:
- a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
-
headMap
public ConcurrentNavigableMap<K,V> headMap(K toKey)
Description copied from interface:ConcurrentNavigableMapReturns a view of the portion of this map whose keys are strictly less than toKey. The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa.- Specified by:
headMapin interfaceConcurrentNavigableMap<K,V>- Specified by:
headMapin interfaceNavigableMap<K,V>- Specified by:
headMapin interfacejava.util.SortedMap<K,V>- Parameters:
toKey- high endpoint (exclusive) of the headMap.- Returns:
- a view of the portion of this map whose keys are strictly less than toKey.
-
tailMap
public ConcurrentNavigableMap<K,V> tailMap(K fromKey)
Description copied from interface:ConcurrentNavigableMapReturns a view of the portion of this map whose keys are greater than or equal to fromKey. The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa.- Specified by:
tailMapin interfaceConcurrentNavigableMap<K,V>- Specified by:
tailMapin interfaceNavigableMap<K,V>- Specified by:
tailMapin interfacejava.util.SortedMap<K,V>- Parameters:
fromKey- low endpoint (inclusive) of the tailMap.- Returns:
- a view of the portion of this map whose keys are greater than or equal to fromKey.
-
ceilingEntry
public java.util.Map.Entry<K,V> ceilingEntry(K key)
Description copied from interface:NavigableMapReturns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such entry.- Specified by:
ceilingEntryin interfaceNavigableMap<K,V>- Parameters:
key- the key.- Returns:
- an Entry associated with ceiling of given key, or null if there is no such Entry.
-
ceilingKey
public K ceilingKey(K key)
Description copied from interface:NavigableMapReturns least key greater than or equal to the given key, or null if there is no such key.- Specified by:
ceilingKeyin interfaceNavigableMap<K,V>- Parameters:
key- the key.- Returns:
- the ceiling key, or null if there is no such key.
-
lowerEntry
public java.util.Map.Entry<K,V> lowerEntry(K key)
Description copied from interface:NavigableMapReturns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such entry.- Specified by:
lowerEntryin interfaceNavigableMap<K,V>- Parameters:
key- the key.- Returns:
- an Entry with greatest key less than the given key, or null if there is no such Entry.
-
lowerKey
public K lowerKey(K key)
Description copied from interface:NavigableMapReturns the greatest key strictly less than the given key, or null if there is no such key.- Specified by:
lowerKeyin interfaceNavigableMap<K,V>- Parameters:
key- the key.- Returns:
- the greatest key less than the given key, or null if there is no such key.
-
floorEntry
public java.util.Map.Entry<K,V> floorEntry(K key)
Description copied from interface:NavigableMapReturns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such entry.- Specified by:
floorEntryin interfaceNavigableMap<K,V>- Parameters:
key- the key.- Returns:
- an Entry associated with floor of given key, or null if there is no such Entry.
-
floorKey
public K floorKey(K key)
Description copied from interface:NavigableMapReturns the greatest key less than or equal to the given key, or null if there is no such key.- Specified by:
floorKeyin interfaceNavigableMap<K,V>- Parameters:
key- the key.- Returns:
- the floor of given key, or null if there is no such key.
-
higherEntry
public java.util.Map.Entry<K,V> higherEntry(K key)
Description copied from interface:NavigableMapReturns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such entry.- Specified by:
higherEntryin interfaceNavigableMap<K,V>- Parameters:
key- the key.- Returns:
- an Entry with least key greater than the given key, or null if there is no such Entry.
-
higherKey
public K higherKey(K key)
Description copied from interface:NavigableMapReturns the least key strictly greater than the given key, or null if there is no such key.- Specified by:
higherKeyin interfaceNavigableMap<K,V>- Parameters:
key- the key.- Returns:
- the least key greater than the given key, or null if there is no such key.
-
firstEntry
public java.util.Map.Entry<K,V> firstEntry()
Description copied from interface:NavigableMapReturns a key-value mapping associated with the least key in this map, or null if the map is empty.- Specified by:
firstEntryin interfaceNavigableMap<K,V>- Returns:
- an Entry with least key, or null if the map is empty.
-
lastEntry
public java.util.Map.Entry<K,V> lastEntry()
Description copied from interface:NavigableMapReturns a key-value mapping associated with the greatest key in this map, or null if the map is empty.- Specified by:
lastEntryin interfaceNavigableMap<K,V>- Returns:
- an Entry with greatest key, or null if the map is empty.
-
pollFirstEntry
public java.util.Map.Entry<K,V> pollFirstEntry()
Description copied from interface:NavigableMapRemoves and returns a key-value mapping associated with the least key in this map, or null if the map is empty.- Specified by:
pollFirstEntryin interfaceNavigableMap<K,V>- Returns:
- the removed first entry of this map, or null if the map is empty.
-
pollLastEntry
public java.util.Map.Entry<K,V> pollLastEntry()
Description copied from interface:NavigableMapRemoves and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.- Specified by:
pollLastEntryin interfaceNavigableMap<K,V>- Returns:
- the removed last entry of this map, or null if the map is empty.
-
keySet
public java.util.Set<K> keySet()
-
descendingKeySet
public java.util.Set<K> descendingKeySet()
Description copied from interface:NavigableMapReturns a set view of the keys contained in this map, in descending key order. 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 (except through the iterator's own remove operation), 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.- Specified by:
descendingKeySetin interfaceNavigableMap<K,V>- Returns:
- a set view of the keys contained in this map.
-
values
public java.util.Collection<V> values()
-
descendingEntrySet
public java.util.Set<java.util.Map.Entry<K,V>> descendingEntrySet()
Description copied from interface:NavigableMapReturns a set view of the mappings contained in this map, in descending key order. Each element in the returned 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 (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) 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.- Specified by:
descendingEntrySetin interfaceNavigableMap<K,V>- Returns:
- a set view of the mappings contained in this map.
-
-