fr.umlv.tatoo.cc.common.util
Class MultiMap<K,V>

java.lang.Object
  extended by fr.umlv.tatoo.cc.common.util.MultiMap<K,V>
Type Parameters:
K - type of the keys
V - 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 Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
MultiMap()
           
 
Method Summary
 boolean add(K key, V value)
          Adds en entry for a given key.
 boolean addAll(MultiMap<? extends K,? extends V> map)
          This become the union of this and m
 boolean addSet(K key, Set<? extends V> values)
          Adds all entries for a given key.
 void clear()
          Clear all entries of this map.
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
protected  Map<K,Set<V>> createMap()
           
protected  Set<V> createSet()
           
 Set<Map.Entry<K,Set<V>>> entrySet()
           
 Set<V> get(Object key)
           
 boolean isEmpty()
           
 Set<K> keySet()
           
 Set<V> put(K key, Set<V> value)
           
 void putAll(Map<? extends K,? extends Set<V>> m)
           
 Set<V> remove(Object key)
           
 int size()
           
 String toString()
           
 Collection<Set<V>> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

MultiMap

public MultiMap()
Method Detail

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>>