@Beta protected class ForwardingNavigableMap.StandardDescendingMap extends ForwardingMap<K,V>
NavigableMap.descendingMap()
in terms of the methods of this
NavigableMap
. In many cases, you may wish to override ForwardingNavigableMap.descendingMap()
to forward to this implementation or a subclass thereof.
In particular, this map iterates over entries with repeated calls to NavigableMap.lowerEntry(K)
. If a more efficient means of iteration is available, you may wish to
override the entryIterator()
method of this class.
ForwardingMap.StandardEntrySet, ForwardingMap.StandardKeySet, ForwardingMap.StandardValues
Constructor and Description |
---|
StandardDescendingMap()
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
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. |
Comparator<? super K> |
comparator()
Returns the comparator used to order the keys in this map, or
null if this map uses the natural ordering of its keys. |
protected Map<K,V> |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
NavigableSet<K> |
descendingKeySet()
Returns a reverse order
NavigableSet view of the keys contained in this map. |
NavigableMap<K,V> |
descendingMap()
Returns a reverse order view of the mappings contained in this map.
|
protected Iterator<Map.Entry<K,V>> |
entryIterator() |
Set<Map.Entry<K,V>> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
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()
Returns the first (lowest) key currently in this map.
|
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. |
SortedMap<K,V> |
headMap(K toKey)
Returns a view of the portion of this map whose keys are
strictly less than
toKey . |
NavigableMap<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. |
Set<K> |
keySet()
Returns a
Set view of the keys contained in this map. |
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()
Returns the last (highest) key currently in this map.
|
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. |
NavigableSet<K> |
navigableKeySet()
Returns a
NavigableSet view of the keys contained in this map. |
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. |
void |
replaceAll(BiFunction<? super K,? super V,? extends V> function)
Replaces each entry's value with the result of invoking the given
function on that entry until all entries have been processed or the
function throws an exception.
|
NavigableMap<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 . |
SortedMap<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. |
SortedMap<K,V> |
tailMap(K fromKey)
Returns a view of the portion of this map whose keys are
greater than or equal to
fromKey . |
NavigableMap<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 . |
String |
toString()
Returns the string representation generated by the delegate's
toString method. |
Collection<V> |
values()
Returns a
Collection view of the values contained in this map. |
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, put, putAll, remove, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
public StandardDescendingMap()
public void replaceAll(BiFunction<? super K,? super V,? extends V> function)
java.util.Map
function
- the function to apply to each entryprotected Iterator<Map.Entry<K,V>> entryIterator()
protected final Map<K,V> delegate()
ForwardingObject
ForwardingSet.delegate()
. Concrete subclasses override this method to supply the
instance being decorated.delegate
in class ForwardingMap<K,V>
public Comparator<? super K> comparator()
java.util.SortedMap
null
if this map uses the natural ordering of its keys.comparator
in interface SortedMap<K,V>
null
if this map uses the natural ordering
of its keyspublic K firstKey()
java.util.SortedMap
public K lastKey()
java.util.SortedMap
public Map.Entry<K,V> lowerEntry(K key)
java.util.NavigableMap
null
if there is
no such key.lowerEntry
in interface NavigableMap<K,V>
key
- the keykey
,
or null
if there is no such keypublic K lowerKey(K key)
java.util.NavigableMap
null
if there is no such key.lowerKey
in interface NavigableMap<K,V>
key
- the keykey
,
or null
if there is no such keypublic Map.Entry<K,V> floorEntry(K key)
java.util.NavigableMap
null
if there
is no such key.floorEntry
in interface NavigableMap<K,V>
key
- the keykey
, or null
if there is no such keypublic K floorKey(K key)
java.util.NavigableMap
null
if there is no such key.floorKey
in interface NavigableMap<K,V>
key
- the keykey
,
or null
if there is no such keypublic Map.Entry<K,V> ceilingEntry(K key)
java.util.NavigableMap
null
if
there is no such key.ceilingEntry
in interface NavigableMap<K,V>
key
- the keykey
, or null
if there is no such keypublic K ceilingKey(K key)
java.util.NavigableMap
null
if there is no such key.ceilingKey
in interface NavigableMap<K,V>
key
- the keykey
,
or null
if there is no such keypublic Map.Entry<K,V> higherEntry(K key)
java.util.NavigableMap
null
if there
is no such key.higherEntry
in interface NavigableMap<K,V>
key
- the keykey
,
or null
if there is no such keypublic K higherKey(K key)
java.util.NavigableMap
null
if there is no such key.higherKey
in interface NavigableMap<K,V>
key
- the keykey
,
or null
if there is no such keypublic Map.Entry<K,V> firstEntry()
java.util.NavigableMap
null
if the map is empty.firstEntry
in interface NavigableMap<K,V>
null
if this map is emptypublic Map.Entry<K,V> lastEntry()
java.util.NavigableMap
null
if the map is empty.lastEntry
in interface NavigableMap<K,V>
null
if this map is emptypublic Map.Entry<K,V> pollFirstEntry()
java.util.NavigableMap
null
if the map is empty.pollFirstEntry
in interface NavigableMap<K,V>
null
if this map is emptypublic Map.Entry<K,V> pollLastEntry()
java.util.NavigableMap
null
if the map is empty.pollLastEntry
in interface NavigableMap<K,V>
null
if this map is emptypublic NavigableMap<K,V> descendingMap()
java.util.NavigableMap
remove
operation), the results of the iteration are undefined.
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 NavigableMap<K,V>
public Set<Map.Entry<K,V>> entrySet()
java.util.Map
Set
view of the mappings contained in this map.
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.public Set<K> keySet()
java.util.Map
Set
view of the keys contained in this map.
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.public NavigableSet<K> navigableKeySet()
java.util.NavigableMap
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. 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.navigableKeySet
in interface NavigableMap<K,V>
public NavigableSet<K> descendingKeySet()
java.util.NavigableMap
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. 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.descendingKeySet
in interface NavigableMap<K,V>
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
java.util.NavigableMap
fromKey
to toKey
. If fromKey
and
toKey
are equal, the returned map is empty unless
fromInclusive
and toInclusive
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 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 viewfromKey
to toKey
public SortedMap<K,V> subMap(K fromKey, K toKey)
java.util.NavigableMap
fromKey
, inclusive, to toKey
, exclusive. (If
fromKey
and toKey
are equal, the returned map
is empty.) 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.
Equivalent to subMap(fromKey, true, toKey, false)
.
subMap
in interface NavigableMap<K,V>
subMap
in interface SortedMap<K,V>
fromKey
- low endpoint (inclusive) of the keys in the returned maptoKey
- high endpoint (exclusive) of the keys in the returned mapfromKey
, inclusive, to toKey
, exclusivepublic NavigableMap<K,V> headMap(K toKey, boolean inclusive)
java.util.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 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 viewinclusive
is true) toKey
public SortedMap<K,V> headMap(K toKey)
java.util.NavigableMap
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.
Equivalent to headMap(toKey, false)
.
headMap
in interface NavigableMap<K,V>
headMap
in interface SortedMap<K,V>
toKey
- high endpoint (exclusive) of the keys in the returned maptoKey
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive)
java.util.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 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 viewinclusive
is true) fromKey
public SortedMap<K,V> tailMap(K fromKey)
java.util.NavigableMap
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.
Equivalent to tailMap(fromKey, true)
.
tailMap
in interface NavigableMap<K,V>
tailMap
in interface SortedMap<K,V>
fromKey
- low endpoint (inclusive) of the keys in the returned mapfromKey
public Collection<V> values()
java.util.Map
Collection
view of the values contained in this map.
The collection is backed by the map, so changes to the map are
reflected in the collection, and vice-versa. If the map is
modified while an iteration over the collection is in progress
(except through the iterator's own remove operation),
the results of the iteration are undefined. The collection
supports element removal, which removes the corresponding
mapping from the map, via the Iterator.remove,
Collection.remove, removeAll,
retainAll and clear operations. It does not
support the add or addAll operations.public String toString()
ForwardingObject
toString
method.toString
in class ForwardingObject
Copyright © 2010–2018. All rights reserved.