Class MultiHashMap

  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by ix.util.MultiHashMap
All Implemented Interfaces:
MultiMap, java.io.Serializable, java.lang.Cloneable, java.util.Map
Direct Known Subclasses:

public class MultiHashMap
extends java.util.HashMap
implements MultiMap

A MultiHashMap is (by weak analogy with "multiset") a HashMap that maps each key to a collection of values. When the first value is added for a given key, the collection that holds that key's values is created by the makeValueCollection method. In this class, it creates a LinkedList, but that can be changed by redefining the method in a subclass.

See Also:
Serialized Form

Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
Nested classes/interfaces inherited from interface java.util.Map
Constructor Summary
Method Summary
 java.lang.Object addValue(java.lang.Object key, java.lang.Object value)
 java.util.Collection makeValueCollection(java.lang.Object firstItem)
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Set the entire colletion of values associated with the key.
 boolean removeValue(java.lang.Object key, java.lang.Object value)
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values

Constructor Detail


public MultiHashMap()
Method Detail


public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Set the entire colletion of values associated with the key.

Specified by:
put in interface java.util.Map
put in class java.util.HashMap


public java.lang.Object addValue(java.lang.Object key,
                                 java.lang.Object value)
Specified by:
addValue in interface MultiMap


public boolean removeValue(java.lang.Object key,
                           java.lang.Object value)
Specified by:
removeValue in interface MultiMap


public java.util.Collection makeValueCollection(java.lang.Object firstItem)
Specified by:
makeValueCollection in interface MultiMap