Defines a map that holds a collection of values against each key.
A
MultiMap
is a Map with slightly different semantics. Putting a value into the map will add the value to a Collection at that key. Getting a value will return a Collection, holding all the values put to that key.
For example:
Number key = new Integer(5); MultiMap<Number,String> mhm = new MultiHashMap<Number,String>(); mhm.put(key, "A"); mhm.put(key, "B"); mhm.put(key, "C"); Collection<String> coll = mhm.get(key);
coll
will be a collection containing "A", "B", "C".
NOTE: Note: this new, generics-friendly version of the MultiMap interface does NOT extend java.util.Map! This is because MultiMap breaks the Map contract in too many ways to allow generics support. However, you can get a live java.util.Map for a MultiMap with the method {@link #map()}.
@author Christopher Berry
@author James Strachan
@author Matt Hall, John Watkinson, Stephen Colebourne
@version $Revision: 1.1 $ $Date: 2005/10/11 17:05:19 $
@since Commons Collections 2.0