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 byConcurrentSkipListMap
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 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) class
ConcurrentSkipListMap.ConcurrentSkipListSubMap.DescendingEntrySetView
(package private) class
ConcurrentSkipListMap.ConcurrentSkipListSubMap.DescendingKeySetView
(package private) class
ConcurrentSkipListMap.ConcurrentSkipListSubMap.EntrySetView
(package private) class
ConcurrentSkipListMap.ConcurrentSkipListSubMap.KeySetView
(package private) class
ConcurrentSkipListMap.ConcurrentSkipListSubMap.ValuesView
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.util.Map.Entry<K,V>>
descendingEntrySetView
private java.util.Set<K>
descendingKeySetView
private java.util.Set<java.util.Map.Entry<K,V>>
entrySetView
private K
fence
upper fence key, or null if to endprivate java.util.Set<K>
keySetView
private K
least
lower bound key, or null if from startprivate ConcurrentSkipListMap<K,V>
m
Underlying mapprivate static long
serialVersionUID
private 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.K
ceilingKey(K key)
Returns least key greater than or equal to the given key, or null if there is no such key.(package private) void
checkKey(K key)
void
clear()
java.util.Comparator<? super K>
comparator()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(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.K
firstKey()
(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.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(java.lang.Object key)
(package private) K
getFence()
Returns fence key.(package private) K
getLeast()
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.K
higherKey(K key)
Returns the least key strictly greater than the given key, or null if there is no such key.(package private) boolean
inHalfOpenRange(K key)
(package private) boolean
inOpenRange(K key)
(package private) boolean
isBeforeEnd(ConcurrentSkipListMap.Node<K,V> n)
boolean
isEmpty()
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.K
lastKey()
(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.K
lowerKey(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.V
put(K key, V value)
V
putIfAbsent(K key, V value)
V
remove(java.lang.Object key)
boolean
remove(java.lang.Object key, java.lang.Object value)
V
replace(K key, V value)
boolean
replace(K key, V oldValue, V newValue)
int
size()
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:ConcurrentNavigableMap
Returns 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:
subMap
in interfaceConcurrentNavigableMap<K,V>
- Specified by:
subMap
in interfaceNavigableMap<K,V>
- Specified by:
subMap
in 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:ConcurrentNavigableMap
Returns 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:
headMap
in interfaceConcurrentNavigableMap<K,V>
- Specified by:
headMap
in interfaceNavigableMap<K,V>
- Specified by:
headMap
in 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:ConcurrentNavigableMap
Returns 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:
tailMap
in interfaceConcurrentNavigableMap<K,V>
- Specified by:
tailMap
in interfaceNavigableMap<K,V>
- Specified by:
tailMap
in 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:NavigableMap
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.- Specified by:
ceilingEntry
in 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:NavigableMap
Returns least key greater than or equal to the given key, or null if there is no such key.- Specified by:
ceilingKey
in 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:NavigableMap
Returns 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:
lowerEntry
in 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:NavigableMap
Returns the greatest key strictly less than the given key, or null if there is no such key.- Specified by:
lowerKey
in 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:NavigableMap
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.- Specified by:
floorEntry
in 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:NavigableMap
Returns the greatest key less than or equal to the given key, or null if there is no such key.- Specified by:
floorKey
in 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:NavigableMap
Returns 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:
higherEntry
in 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:NavigableMap
Returns the least key strictly greater than the given key, or null if there is no such key.- Specified by:
higherKey
in 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:NavigableMap
Returns a key-value mapping associated with the least key in this map, or null if the map is empty.- Specified by:
firstEntry
in 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:NavigableMap
Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.- Specified by:
lastEntry
in 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:NavigableMap
Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.- Specified by:
pollFirstEntry
in 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:NavigableMap
Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.- Specified by:
pollLastEntry
in 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:NavigableMap
Returns 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:
descendingKeySet
in 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:NavigableMap
Returns 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:
descendingEntrySet
in interfaceNavigableMap<K,V>
- Returns:
- a set view of the mappings contained in this map.
-
-