ix.util
Class MultiHashMap

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--ix.util.MultiHashMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, MultiMap, java.io.Serializable

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

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
MultiHashMap()
           
 
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)
           
 boolean removeValue(java.lang.Object key, java.lang.Object value)
           
 
Methods inherited from class java.util.HashMap
, capacity, clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, loadFactor, 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

MultiHashMap

public MultiHashMap()
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.HashMap

addValue

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

removeValue

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

makeValueCollection

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