Package io.permazen.util
Class ConvertedNavigableMap<K,V,WK,WV>
java.lang.Object
java.util.AbstractMap<K,V>
io.permazen.util.AbstractNavigableMap<K,V>
io.permazen.util.ConvertedNavigableMap<K,V,WK,WV>
- Type Parameters:
K
- key type of this mapV
- value type of this mapWK
- key type of wrapped mapWV
- value type of wrapped map
- All Implemented Interfaces:
Map<K,
,V> NavigableMap<K,
,V> SortedMap<K,
V>
Provides a transformed view of a wrapped
NavigableMap
using a strictly invertible Converter
.
Supplied Converter
s may throw ClassCastException
or IllegalArgumentException
if given an objects whose runtime type does not match the expected type.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
Fields inherited from class io.permazen.util.AbstractNavigableMap
bounds
-
Constructor Summary
ConstructorDescriptionConvertedNavigableMap
(NavigableMap<WK, WV> map, Converter<K, WK> keyConverter, Converter<V, WV> valueConverter) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Comparator<? super K>
protected NavigableMap<K,
V> createSubMap
(boolean reverse, Bounds<K> newBounds) Create a (possibly reversed) view of this instance with (possibly) tighter lower and/or upper bounds.entrySet()
boolean
isEmpty()
Removes the mapping for a key from this map if it is present.searchAbove
(K minKey, boolean inclusive) Search for a higher element.searchBelow
(K maxKey, boolean inclusive) Search for a lower element.int
size()
Methods inherited from class io.permazen.util.AbstractNavigableMap
ceilingEntry, ceilingKey, containsKey, descendingKeySet, descendingMap, firstEntry, firstKey, floorEntry, floorKey, getBounds, getComparator, headMap, headMap, higherEntry, higherKey, isWithinLowerBound, isWithinUpperBound, keySet, lastEntry, lastKey, lowerEntry, lowerKey, pollFirstEntry, pollLastEntry, subMap, subMap, tailMap, tailMap
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, putAll, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, getOrDefault, hashCode, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
Method Details
-
getKeyConverter
-
getValueConverter
-
comparator
-
get
-
entrySet
-
put
-
remove
Description copied from class:AbstractNavigableMap
Removes the mapping for a key from this map if it is present.The implementation in
AbstractNavigableMap
always throwsUnsupportedOperationException
. -
clear
public void clear() -
isEmpty
public boolean isEmpty() -
size
public int size() -
searchBelow
Description copied from class:AbstractNavigableMap
Search for a lower element. Used to implementfloorEntry()
andlowerEntry()
.The implementation in
AbstractNavigableMap
checks the bounds then returns the first entry from a head map.- Overrides:
searchBelow
in classAbstractNavigableMap<K,
V> - Parameters:
maxKey
- upper limit for searchinclusive
- true ifmaxKey
itself is a candidate- Returns:
- highest element below
maxKey
, or null if not found
-
searchAbove
Description copied from class:AbstractNavigableMap
Search for a higher element. Used to implementceilingEntry()
andhigherEntry()
.The implementation in
AbstractNavigableMap
checks the bounds then returns the first entry from a tail map.- Overrides:
searchAbove
in classAbstractNavigableMap<K,
V> - Parameters:
minKey
- lower limit for searchinclusive
- true ifminKey
itself is a candidate- Returns:
- lowest element above
minKey
, or null if not found
-
createSubMap
Description copied from class:AbstractNavigableMap
Create a (possibly reversed) view of this instance with (possibly) tighter lower and/or upper bounds. ThenewBounds
are consistent with the new ordering (i.e., reversed relative to this instance's ordering ifreverse
is true) and have already been range-checked against this instance's current bounds.- Specified by:
createSubMap
in classAbstractNavigableMap<K,
V> - Parameters:
reverse
- whether the new map's ordering should be reversed relative to this instance's orderingnewBounds
- new bounds- Returns:
- restricted and/or reversed view of this instance
-