K - the type of the keys the map uses.V - the type of the values the map uses.public class MultiMap<K,V>
extends java.lang.Object
This MultiMap uses a LinkedHashMap together with a ArrayList in order to keep the order of its entries.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAP_SIZE
The constant value 6.
|
| Constructor and Description |
|---|
MultiMap()
Constructs a new MultiMap with a initial capacity of
DEFAULT_MAP_SIZE. |
MultiMap(int size)
Constructs a new MultiMap.
|
| Modifier and Type | Method and Description |
|---|---|
MultiMap<K,V> |
asUnmodifiableMultiMap() |
void |
clear() |
boolean |
containsKey(K key) |
boolean |
containsValue(V value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
java.util.List<V> |
getAll(K key)
Get all values for the given key.
|
V |
getFirst(K key)
Get the first value for the given key, or
null if there are no entries. |
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
boolean |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> map) |
V |
remove(K key)
Removes all mappings for the given key and returns the first value if there where mappings or
null if not. |
java.util.List<V> |
remove(K key,
int num)
Remove the given number of values for a given key.
|
boolean |
removeOne(K key,
V value)
Remove the mapping of the given key to the value.
|
int |
size() |
java.util.List<V> |
values()
Returns a new list containing all values of this multi map.
|
public static final int DEFAULT_MAP_SIZE
public MultiMap()
DEFAULT_MAP_SIZE.public MultiMap(int size)
size - the initial capacity.public int size()
public boolean isEmpty()
public boolean containsKey(K key)
public boolean containsValue(V value)
public V getFirst(K key)
null if there are no entries.key - public java.util.List<V> getAll(K key)
Changes to the returned set will update the underlying MultiMap if the return set is not empty.
key - public V remove(K key)
null if not.key - public boolean removeOne(K key, V value)
Returns true if the mapping was removed and false if the mapping did not exist.
key - value - public java.util.List<V> remove(K key, int num)
key - the key to remove from.num - the number of values to remove.public void clear()
public java.util.Set<K> keySet()
public java.util.List<V> values()