|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--java.util.AbstractMap
|
+--java.util.HashMap
|
+--org.apache.commons.collections.MultiHashMap
MultiHashMap is the default implementation of the
MultiMap interface.
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 always return a Collection, holding all the
values put to that key. This implementation uses an ArrayList as the
collection.
For example:
MultiMap mhm = new MultiHashMap(); mhm.put(key, "A"); mhm.put(key, "B"); mhm.put(key, "C"); Collection coll = mhm.get(key);
coll will be a list containing "A", "B", "C".
| Constructor Summary | |
MultiHashMap()
Constructor. |
|
MultiHashMap(int initialCapacity)
Constructor. |
|
MultiHashMap(int initialCapacity,
float loadFactor)
Constructor. |
|
MultiHashMap(java.util.Map mapToCopy)
Constructor. |
|
| Method Summary | |
void |
clear()
Clear the map. |
java.lang.Object |
clone()
Clone the map. |
boolean |
containsValue(java.lang.Object value)
Does the map contain a specific value. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Put a key and value into the map. |
java.lang.Object |
remove(java.lang.Object key,
java.lang.Object item)
Removes a specific value from map. |
java.util.Collection |
values()
Gets a view over all the values in the map. |
| Methods inherited from class java.util.HashMap |
containsKey, entrySet, get, isEmpty, keySet, putAll, remove, size |
| Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
containsKey, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size |
| Constructor Detail |
public MultiHashMap()
public MultiHashMap(int initialCapacity)
initialCapacity - the initial map capacity
public MultiHashMap(int initialCapacity,
float loadFactor)
initialCapacity - the initial map capacityloadFactor - the amount 0.0-1.0 at which to resize the mappublic MultiHashMap(java.util.Map mapToCopy)
mapToCopy - a Map to copy| Method Detail |
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
The value is added to a collection mapped to the key instead of replacing the previous value.
put in interface java.util.Mapput in class java.util.HashMapkey - the key to setvalue - the value to set the key to
null otherwisepublic boolean containsValue(java.lang.Object value)
This searches the collection mapped to each key, and thus could be slow.
containsValue in interface java.util.MapcontainsValue in class java.util.HashMapvalue - the value to search for
public java.lang.Object remove(java.lang.Object key,
java.lang.Object item)
The item is removed from the collection mapped to the specified key.
remove in interface MultiMapkey - the key to remove fromitem - the value to remove
public void clear()
This clears each collection in the map, and so may be slow.
clear in interface java.util.Mapclear in class java.util.HashMappublic java.util.Collection values()
The values view includes all the entries in the collections at each map key.
values in interface java.util.Mapvalues in class java.util.HashMappublic java.lang.Object clone()
The clone will shallow clone the collections as well as the map.
clone in class java.util.HashMap
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||