K
- keyV
- valuepublic class KeyInValueMap<K,V> extends AbstractMap<K,V>
Map
facade which stores values that also reference their
own keys.Modifier and Type | Class and Description |
---|---|
static interface |
KeyInValueMap.KeyFromValueAdapter<K,V>
Adapter interface that clients of the class should implement
and pass to its constructor so that the key (K) can be derived
from the value (V).
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
KeyInValueMap(KeyInValueMap.KeyFromValueAdapter<K,V> adapter)
Create a new instance
|
KeyInValueMap(KeyInValueMap.KeyFromValueAdapter<K,V> adapter,
Map<K,V> map)
Create a new instance, given the existing map
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(V value)
Add a value to this map where its key will be derived
by the
KeyInValueMap.KeyFromValueAdapter |
Set<Map.Entry<K,V>> |
entrySet() |
V |
put(K key,
V value) |
V |
remove(Object value)
Remove a value from this map where the key will
be determined by the
KeyInValueMap.KeyFromValueAdapter |
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, size, toString, values
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public KeyInValueMap(KeyInValueMap.KeyFromValueAdapter<K,V> adapter)
adapter
- that can convert from the value into the keypublic boolean add(V value)
KeyInValueMap.KeyFromValueAdapter
value
- the Valuepublic V remove(Object value)
KeyInValueMap.KeyFromValueAdapter
Copyright © 2013–2019. All rights reserved.