org.elkoserver.util
Class HashMapMulti<K,V>

java.lang.Object
  extended by org.elkoserver.util.HashMapMulti<K,V>

public class HashMapMulti<K,V>
extends Object

A hashtable-like collection that maps each key to a set of items rather than to a single item.


Constructor Summary
HashMapMulti()
          Construct an empty map.
 
Method Summary
 void add(K key, V value)
          Add a value to a key's value set.
 boolean containsKey(K key)
          Test if this map has a mapping for a given key.
 HashSetMulti<V> getMulti(K key)
          Return the set of values for some key.
 Set<K> keys()
          Get the set of keys for this map.
 void remove(K key)
          Remove a key's entire value set.
 void remove(K key, V value)
          Remove a value from a key's value set.
 Iterable<V> values()
          Return an iterable that can iterate over all the values of all the keys in this map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapMulti

public HashMapMulti()
Construct an empty map.

Method Detail

add

public void add(K key,
                V value)
Add a value to a key's value set.

Parameters:
key - The key for the value to add.
value - The value that should be added to 'key's value set

containsKey

public boolean containsKey(K key)
Test if this map has a mapping for a given key.

Parameters:
key - The key whose potential mapping is of interest.
Returns:
true if this map has one or more values for key, false if not.

getMulti

public HashSetMulti<V> getMulti(K key)
Return the set of values for some key. Note that a set will always be returned; if the given key has no values then the set returned will be empty.

Parameters:
key - The key for the set of values desired.
Returns:
a set of the values for 'key'.

keys

public Set<K> keys()
Get the set of keys for this map.

Returns:
the keys for this map.

remove

public void remove(K key,
                   V value)
Remove a value from a key's value set.

Parameters:
key - The key for the value set to remove from.
value - The value that should be removed from 'key's value set

remove

public void remove(K key)
Remove a key's entire value set.

Parameters:
key - The key for the set of values to remove.

values

public Iterable<V> values()
Return an iterable that can iterate over all the values of all the keys in this map.

Returns:
an iterable for the values in this map.