Deprecated
since 4.1, use MultiValuedMap instead
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 MultiValueMap(); 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.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the map contains the valuethe value to search for value)Redeclares java. |
| public Object | Returns: theCollection of values, implementations should
return null for no mapping, but may return an empty collectionthe key to retrieve key)Redeclares java. |
| public Object | Returns: typically the value added if the map changed and null if the map did not changethe key to store against key, Object the value to add to the collection at the key value)Redeclares java. |
| public Object | Returns: theCollection of values removed, implementations should
return null for no mapping found, but may return an empty collectionthe key to remove values from key)Redeclares java. |
| public boolean | Returns: true if the mapping was removed, false otherwisethe key to remove from key, V the item to remove item)Removes a specific value from map. |
| public int | Returns: the number of key-collection mappings in this mapRedeclares java. |
| public Collection | Returns: a collection view of the values contained in this mapRedeclares java. |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) Redeclares java. Checks whether the map contains the value specified. Implementations typically check all collections against all keys for the value. This cannot be mandated due to backwards compatibility of this interface.
| |
| get | back to summary |
|---|---|
| public Object get(Object key) Redeclares java. Gets the collection of values associated with the specified key.
The returned value will implement
Implementations typically return Implementations may choose to return a clone of the internal collection.
| |
| put | back to summary |
|---|---|
| public Object put(K key, Object value) Redeclares java. Adds the value to the collection associated with the specified key.
Unlike a normal
| |
| remove | back to summary |
|---|---|
| public Object remove(Object key) Redeclares java. Removes all values associated with the specified key.
Implementations typically return
| |
| removeMapping | back to summary |
|---|---|
| public boolean removeMapping(K key, V item) Removes a specific value from map. The item is removed from the collection mapped to the specified key. Other values attached to that key are unaffected.
If the last value for a key is removed, implementations typically
return
| |
| size | back to summary |
|---|---|
| public int size() Redeclares java. Gets the number of keys in this map. Implementations typically return only the count of keys in the map This cannot be mandated due to backwards compatibility of this interface.
| |
| values | back to summary |
|---|---|
| public Collection Redeclares java. Gets a collection containing all the values in the map. Implementations typically return a collection containing the combination of values from all keys. This cannot be mandated due to backwards compatibility of this interface.
| |