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 void
clear()
V
compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
V
computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
V
computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<K,V>>
entrySet()
boolean
equals(Object o)
void
forEach(BiConsumer<? super K,? super V> action)
V
get(Object key)
V
getByIndex(int index)
V
getOrDefault(Object key, V defaultValue)
int
hashCode()
boolean
isEmpty()
Set<K>
keySet()
V
merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
putIfAbsent(K key, V value)
V
remove(Object key)
boolean
remove(Object key, Object value)
V
replace(K key, V value)
boolean
replace(K key, V oldValue, V newValue)
void
replaceAll(BiFunction<? super K,? super V,? extends V> function)
int
size()
Collection<V>
values()
-
Constructor Details
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
equals
-
hashCode
public int hashCode() -
getOrDefault
- Specified by:
getOrDefault
in interfaceMap<K,V>
-
forEach
-
replaceAll
- Specified by:
replaceAll
in interfaceMap<K,V>
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceMap<K,V>
-
remove
-
replace
-
replace
-
computeIfAbsent
- Specified by:
computeIfAbsent
in interfaceMap<K,V>
-
computeIfPresent
- Specified by:
computeIfPresent
in interfaceMap<K,V>
-
compute
-
merge
-
getByIndex
-