public class MultiMap<K,V>
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<K,java.util.ArrayList<V>> |
mMap |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(K key) |
boolean |
containsValue(V val) |
java.util.List<V> |
get(K key)
Get the collection of values associated with a given key.
|
boolean |
isEmpty() |
java.util.Set<K> |
keySet()
Get a set of all the keys in this map.
|
void |
put(K key,
java.util.Collection<V> values)
Add a key to the map with a collection of elements.
|
void |
put(K key,
V value)
Add an element to the map.
|
V |
remove(K key,
V value)
Remove one value from an existing key.
|
java.util.Collection<V> |
removeKey(K key)
Remove all the values associated with the given key
|
int |
size()
Get the number of keys in the map.
|
java.lang.String |
toString() |
java.util.Collection<V> |
values()
Get a single collection of all the values in the map.
|
public MultiMap()
public MultiMap(int size)
size
- Initial size of the mappublic void put(K key, V value)
key
- The key to store the value under. If the key already
exists the value will be added to the collection for that key, it
will not replace the existing value (as in a standard map).value
- value to store.public void put(K key, java.util.Collection<V> values)
key
- The key to store the value under. If the key already
exists the value will be added to the collection for that key, it
will not replace the existing value (as in a standard map).values
- collection of values to store.public java.util.List<V> get(K key)
key
- Key to fetch values for.public V remove(K key, V value)
key
- Key to remove the value from.value
- Value to remove.public java.util.Collection<V> removeKey(K key)
key
- the key to be removedpublic java.util.Set<K> keySet()
public java.util.Collection<V> values()
public java.lang.String toString()
toString
in class java.lang.Object
public int size()
public boolean isEmpty()
public void clear()
public boolean containsKey(K key)
public boolean containsValue(V val)
Copyright © 2007-2012 The Apache Software Foundation