fr.umlv.tatoo.cc.common.util
Class MultiMap<K,V>
java.lang.Object
fr.umlv.tatoo.cc.common.util.MultiMap<K,V>
- Type Parameters:
K
- type of the keysV
- type of the values
- All Implemented Interfaces:
- Map<K,Set<V>>
public class MultiMap<K,V>
- extends Object
- implements Map<K,Set<V>>
Maps which associates an object to a set of values.
- Author:
- remi, julien
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
MultiMap
public MultiMap()
createMap
protected Map<K,Set<V>> createMap()
createSet
protected Set<V> createSet()
clear
public void clear()
- Clear all entries of this map.
- Specified by:
clear
in interface Map<K,Set<V>>
values
public Collection<Set<V>> values()
- Specified by:
values
in interface Map<K,Set<V>>
add
public boolean add(K key,
V value)
- Adds en entry for a given key.
- Parameters:
key
- key of the entry.value
- value of the entry.
- Returns:
- true if the value is not already present.
addSet
public boolean addSet(K key,
Set<? extends V> values)
- Adds all entries for a given key.
- Parameters:
key
- key of the entries.values
- values corresponding to the key.
- Returns:
- true if values have been added
keySet
public Set<K> keySet()
- Specified by:
keySet
in interface Map<K,Set<V>>
get
public Set<V> get(Object key)
- Specified by:
get
in interface Map<K,Set<V>>
- Returns:
- set of values associated with key
entrySet
public Set<Map.Entry<K,Set<V>>> entrySet()
- Specified by:
entrySet
in interface Map<K,Set<V>>
addAll
public boolean addAll(MultiMap<? extends K,? extends V> map)
- This become the union of this and m
- Parameters:
map
- the map that contains entry to add.
- Returns:
- true if the current multi-map is modified.
remove
public Set<V> remove(Object key)
- Specified by:
remove
in interface Map<K,Set<V>>
toString
public String toString()
- Overrides:
toString
in class Object
size
public int size()
- Specified by:
size
in interface Map<K,Set<V>>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface Map<K,Set<V>>
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interface Map<K,Set<V>>
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interface Map<K,Set<V>>
put
public Set<V> put(K key,
Set<V> value)
- Specified by:
put
in interface Map<K,Set<V>>
putAll
public void putAll(Map<? extends K,? extends Set<V>> m)
- Specified by:
putAll
in interface Map<K,Set<V>>