K
- the type of keyV
- the type of valuespublic class ValueListMap<K,V>
extends java.util.concurrent.ConcurrentHashMap<K,java.util.List<V>>
A map implementation that stores a list of values for each key. To remain consistent with existing Map interfaces the put* methods perform replacement of keys with new lists of values, the addValue* methods should be used to add new values to the existing keys.
Note that when using put to add a list of values for a key that later calls to addValue* will modify the original list. Consequently if the list is not modifiable then these operations will fail (typically with an UnsupportedOperationException).
This implementation does not currently support removing some values from a key.
java.util.concurrent.ConcurrentHashMap.KeySetView<K,V>
Constructor and Description |
---|
ValueListMap() |
Modifier and Type | Method and Description |
---|---|
void |
addValuesToKey(K key,
java.util.Collection<V> valueCollection)
Add a collection of one or more values to the map under the existing key or creating a new key
if it does not yet exist in the map.
|
void |
addValueToKey(K key,
V value)
Add a value to the map under the existing key or creating a new key if it does not
yet exist.
|
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
public void addValueToKey(K key, V value)
key
- the key to associate the values withvalue
- the value to add to the keypublic void addValuesToKey(K key, java.util.Collection<V> valueCollection)
key
- the key to associate the values withvalueCollection
- a collection of values to add to the key