Implemented as a map of LazyList values @see LazyList @author Greg Wilkins (gregw)
The methods {@link #get}, {@link #keySet}, {@link #keys}, {@link #values}, {@link #entries}, and {@link #asMap} return collections that are views of themultimap. If the multimap is modifiable, updating it can change the contents of those collections, and updating the collections will change the multimap. In contrast, {@link #replaceValues} and {@link #removeAll} return collectionsthat are independent of subsequent multimap changes.
Depending on the implementation, a multimap may or may not allow duplicate key-value pairs. In other words, the multimap contents after adding the same key and value twice varies between implementations. In multimaps allowing duplicates, the multimap will contain two mappings, and {@code get} willreturn a collection that includes the value twice. In multimaps not supporting duplicates, the multimap will contain a single mapping from the key to the value, and {@code get} will return a collection that includes thevalue once.
All methods that alter the multimap are optional, and the views returned by the multimap may or may not be modifiable. When modification isn't supported, those methods will throw an {@link UnsupportedOperationException}. @author Jared Levy @param < K> the type of keys maintained by this multimap @param < V> the type of mapped values @since Guava release 02 (imported from Google Collections Library)
Gotchas:
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:
MultiMap mhm = new MultiHashMap(); mhm.put(key, "A"); mhm.put(key, "B"); mhm.put(key, "C"); Collection coll = (Collection) mhm.get(key);
coll
will be a collection containing "A", "B", "C".
NOTE: Additional methods were added to this interface in Commons Collections 3.1. These were added solely for documentation purposes and do not change the interface as they were defined in the superinterface Map
anyway.
@since Commons Collections 2.0
@version $Revision: 1.12 $ $Date: 2004/03/14 15:33:57 $
@author Christopher Berry
@author James Strachan
@author Stephen Colebourne
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
Implemented as a map of LazyList values @see LazyList @version $Id: MultiMap.java,v 1.18 2004/12/15 02:13:51 gregwilkins Exp $ @author Greg Wilkins (gregw)
MultiMap
, which is basically a Map with multiple values for a key. This will be removed when SUN see sense and include it in the JDK java.util package as standard.
MultiMap
, which is basically a Map with multiple values for a key. This will be removed when SUN see sense and include it in the JDK java.util package as standard.
@version $Revision: 1.6 $
Implemented as a map of LazyList values @see LazyList @author Greg Wilkins (gregw)
Implemented as a map of LazyList values @see LazyList @version $Id: MultiMap.java,v 1.18 2004/12/15 02:13:51 gregwilkins Exp $ @author Greg Wilkins (gregw)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|