Interface ValueSortedMap<K,V>
- Type Parameters:
K
- the type of the keysV
- the type of the values
- All Known Implementing Classes:
RestrictedValueSortedMap
,TreeValueSortedMap
This is an extension of Map
where entries are sorted by value, rather than by key. Such a
map may be useful as a priority queue where the cost of an entry may change over time. As such,
the collections returned by entrySet()
, keySet()
, and values()
all
extend Deque
. The order of the entries will be updated on any call to
Map.put(Object, Object)
, or a call to Collection.add(Object)
on the entry set.
Additionally, if the values are mutable objects, whose order may change, there is an
update(Object)
method, which notifies the map that the given key may need to be
repositioned. The associated collections also extend the List
interface, providing fairly
efficient implementations of List.get(int)
and List.indexOf(Object)
. Sequential
access is best performed via Collection.iterator()
, since this will use a linked list.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
An interface with a subset of methods fromList
.static interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptionceilingEntryByValue
(V value) Returns a key-value mapping associated with the least value greater than or equal to the given value, ornull
if there is no such value.void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
floorEntryByValue
(V value) Returns a key-value mapping associated with the greatest value less than or equal to the given value, ornull
if there is no such value.headMapByValue
(V toValue, boolean inclusive) Returns a view of the portion of this map whose values are less than (or equal to, ifinclusive
is true)toValue
.higherEntryByValue
(V value) Returns a key-value mapping associated with the least value strictly greater than the given value, ornull
if there is no such value.boolean
isEmpty()
keySet()
lowerEntryByValue
(V value) Returns a key-value mapping associated with the greatest value strictly less than the given value, ornull
if there is no such value.int
size()
subMapByValue
(V fromValue, boolean fromInclusive, V toValue, boolean toInclusive) Returns a view of the portion of this map whose values range fromfromValue
totoValue
.tailMapByValue
(V fromValue, boolean inclusive) Returns a view of the portion of this map whose values are greater than (or equal to, ifinclusive
is true)toValue
.boolean
Notify the map of an external change to the cost of a key's associated valuevalues()
-
Method Details
-
put
-
get
-
remove
-
entrySet
ValueSortedMap.ValueSortedMapEntryList<K,V> entrySet() -
lowerEntryByValue
Returns a key-value mapping associated with the greatest value strictly less than the given value, ornull
if there is no such value.- Parameters:
value
- the value- Returns:
- the found entry, or
null
-
floorEntryByValue
Returns a key-value mapping associated with the greatest value less than or equal to the given value, ornull
if there is no such value.- Parameters:
value
- the value- Returns:
- the found entry, or
null
-
ceilingEntryByValue
Returns a key-value mapping associated with the least value greater than or equal to the given value, ornull
if there is no such value.- Parameters:
value
- the value- Returns:
- the found entry, or
null
-
higherEntryByValue
Returns a key-value mapping associated with the least value strictly greater than the given value, ornull
if there is no such value.- Parameters:
value
- the value- Returns:
- the found entry, or
null
-
subMapByValue
ValueSortedMap<K,V> subMapByValue(V fromValue, boolean fromInclusive, V toValue, boolean toInclusive) Returns a view of the portion of this map whose values range fromfromValue
totoValue
. The returned map is an unmodifiable view.- Parameters:
fromValue
- low endpoint of the values in the returned mapfromInclusive
-true
if the low endpoint is to be included in the returned viewtoValue
- high endpoint of the values in the returned maptoInclusive
-true
if the high endpoint is to be included in the returned view- Returns:
- the view
-
headMapByValue
Returns a view of the portion of this map whose values are less than (or equal to, ifinclusive
is true)toValue
. The returned map is an unmodifiable view.- Parameters:
toValue
- high endpoint of the values in the returned mapinclusive
-true
if the high endpoint is to be included in the returned view- Returns:
- the view
-
tailMapByValue
Returns a view of the portion of this map whose values are greater than (or equal to, ifinclusive
is true)toValue
. The returned map is an unmodifiable view.- Parameters:
fromValue
- low endpoint of the values in the returned mapinclusive
-true
if the low endpoint is to be included in the returned view- Returns:
- the view
-
keySet
ValueSortedMap.ValueSortedMapKeyList<K> keySet() -
update
Notify the map of an external change to the cost of a key's associated valueThis is meant to update the entry's position after a change in cost. The position may not necessarily change, however, if the cost did not change significantly.
- Parameters:
key
- the key whose associated value has changed in cost- Returns:
- true if the entry's position changed
-
values
SortedList<V> values() -
isEmpty
boolean isEmpty() -
containsKey
-
containsValue
-
size
int size() -
clear
void clear()
-