K - the key typeV - the value typepublic class Multimap<K,V> extends Object implements Map<K,List<V>>
LinkedHashMap with LinkedList to store multiple values.
This class is NOT thread-safe.| Constructor and Description |
|---|
Multimap()
Create an empty Multimap.
|
Multimap(int initialCapacity)
Create an empty Multimap with a given initial capacity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(K key,
V value)
Add a value to the list of values under the given key.
|
void |
addAll(K key,
Collection<? extends V> values)
Add multiple values to the list of values under the given key.
|
void |
addAll(Multimap<K,V> values)
Add all values from the given
Multimap to the current ones. |
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Multimap<K,V> |
deepCopy()
Clone this
Multimap using a deep copy, including each stored value list. |
Set<Map.Entry<K,List<V>>> |
entrySet() |
List<V> |
get(Object key) |
boolean |
isEmpty() |
Set<K> |
keySet() |
List<V> |
put(K key,
List<V> value) |
void |
putAll(Map<? extends K,? extends List<V>> m) |
List<V> |
remove(Object key) |
void |
set(K key,
V value)
Set a value under the given key, replacing any existing single or multiple values.
|
void |
setAll(Map<K,V> values)
Set multiple values under the given key, replacing any existing single or multiple values.
|
int |
size() |
Collection<List<V>> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic Multimap()
public Multimap(int initialCapacity)
initialCapacity - the initial capacitypublic void add(K key, V value)
key - the keyvalue - the value to addpublic void addAll(K key, Collection<? extends V> values)
key - the keyvalues - the values to addpublic void addAll(Multimap<K,V> values)
Multimap to the current ones.values - the values to addpublic void set(K key, V value)
key - the keyvalue - the value to setpublic void setAll(Map<K,V> values)
values - the values to setpublic Multimap<K,V> deepCopy()
Multimap using a deep copy, including each stored value list.Multimappublic boolean containsKey(Object key)
containsKey in interface Map<K,List<V>>public boolean containsValue(Object value)
containsValue in interface Map<K,List<V>>