Package com.illumon.util.datastructures
Class SortedIndexableMapWrapper<K,V>
java.lang.Object
com.illumon.util.datastructures.SortedIndexableMapWrapper<K,V>
- All Implemented Interfaces:
com.fishlib.base.hash.IndexableMap<K,V>,Map<K,V>
public class SortedIndexableMapWrapper<K,V> extends Object implements com.fishlib.base.hash.IndexableMap<K,V>
This is a simple utility class that wraps a map, and presents it as an IndexableMap.
The getByIndex() and values() method sort the values according the passed in Comparator.
The other access methods (iteration, keySet etc. do not sort the results).
Everything that touches the values list should be synchronized.
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description SortedIndexableMapWrapper(Map<K,V> baseMap, Comparator<V> comparator) -
Method Summary
Modifier and Type Method Description voidclear()Vcompute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)VcomputeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)VcomputeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()booleanequals(Object o)voidforEach(BiConsumer<? super K,? super V> action)Vget(Object key)VgetByIndex(int index)VgetOrDefault(Object key, V defaultValue)inthashCode()booleanisEmpty()Set<K>keySet()Vmerge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)VputIfAbsent(K key, V value)Vremove(Object key)booleanremove(Object key, Object value)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)voidreplaceAll(BiFunction<? super K,? super V,? extends V> function)intsize()Collection<V>values()
-
Constructor Details
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
equals
-
hashCode
public int hashCode() -
getOrDefault
- Specified by:
getOrDefaultin interfaceMap<K,V>
-
forEach
-
replaceAll
- Specified by:
replaceAllin interfaceMap<K,V>
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceMap<K,V>
-
remove
-
replace
-
replace
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceMap<K,V>
-
computeIfPresent
- Specified by:
computeIfPresentin interfaceMap<K,V>
-
compute
-
merge
-
getByIndex
-