MultiHashMap
is the default implementation of the {@link org.apache.commons.collections15.MultiMap MultiMap} interface.
A
MultiMap
is like a Map, but 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.
This implementation uses an
ArrayList
as the collection. The internal storage list is made available without cloning via the
get(Object)
and
entrySet()
methods. The implementation returns
null
when there are no values mapped to a 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);
list
will be a list containing "A", "B", "C".
@author Christopher Berry
@author James Strachan
@author Steve Downey
@author Stephen Colebourne
@author Julien Buret
@author Matt Hall, John Watkinson, Serhiy Yevtushenko
@version $Revision: 1.2 $ $Date: 2006/06/08 15:19:55 $
@since Commons Collections 2.0