A MultiValuedMap is a Map with slightly different semantics:
Collection at that key.Collection, holding all the values put to that key.For example:
MultiValuedMap<K, String> map = new MultiValuedHashMap<K, String>(); map.put(key, "A"); map.put(key, "B"); map.put(key, "C"); Collection<String> coll = map.get(key);
coll will be a collection containing "A", "B", "C".
| Modifier and Type | Method and Description |
|---|---|
| public Map | Returns: a map view of the mappings in this multi-valued mapReturns a view of this multi-valued map as a |
| public void | |
| public boolean | Returns: true if this map contains a mapping for the specified keykey whose presence in this map is to be tested key)Returns |
| public boolean | Returns: true if the map contains the valuethe key to search for key, Object the value to search for value)Checks whether the map contains a mapping for the specified key and value. |
| public boolean | Returns: true if the map contains the valuethe value to search for value)Checks whether the map contains at least one mapping for the specified value. |
| public Collection | Returns: a set view of the mappings contained in this mapReturns a |
| public Collection | Returns: theCollection of values, implementations should
return an empty collection for no mappingthe key to retrieve key)Returns a view collection of the values associated with the specified key. |
| public boolean | Returns: true if this map contains no key-value mappingsReturns |
| public MultiSet | |
| public Set | |
| public MapIterator | |
| public boolean | Returns: true if the map changed as a result of this put operation, or false if the map already contained the key-value mapping and the collection type does not allow duplicate values, e.g. when using a Setthe key to store against key, V the value to add to the collection at the key value)Adds a key-value mapping to this multi-valued map. |
| public boolean | |
| public boolean | |
| public boolean | Returns: true if the map changed as a result of this operationmappings to be stored in this map, may not be null map)Copies all mappings from the specified map to this multi-valued map (optional operation). |
| public Collection | |
| public boolean | Returns: true if the mapping was removed, false otherwisethe key to remove from key, Object the item to remove item)Removes a key-value mapping from the map. |
| public int | |
| public Collection | Returns: a collection view of the values contained in this multi-valued mapGets a |
| asMap | back to summary |
|---|---|
| public Map Returns a view of this multi-valued map as a
Note that
Changes to the returned map or the collections that serve as its values
will update the underlying multi-valued map, and vice versa. The map does
not support
| |
| clear | back to summary |
|---|---|
| public void clear() Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object key) Returns
| |
| containsMapping | back to summary |
|---|---|
| public boolean containsMapping(Object key, Object value) Checks whether the map contains a mapping for the specified key and value. | |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) Checks whether the map contains at least one mapping for the specified value.
| |
| entries | back to summary |
|---|---|
| public Collection Returns a The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.
| |
| get | back to summary |
|---|---|
| public Collection Returns a view collection of the values associated with the specified key.
This method will return an empty collection if
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns
| |
| keys | back to summary |
|---|---|
| public MultiSet Returns a
The This multiset is backed by the map, so any changes in the map are reflected in the multiset.
| |
| keySet | back to summary |
|---|---|
| public Set Returns a The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
If the map is modified while an iteration over the set is in
progress (except through the iterator's own
| |
| mapIterator | back to summary |
|---|---|
| public MapIterator Obtains a
A map iterator is an efficient way of iterating over maps. There is no
need to access the entries collection or use
| |
| put | back to summary |
|---|---|
| public boolean put(K key, V value) Adds a key-value mapping to this multi-valued map.
Unlike a normal
The method will return
| |
| putAll | back to summary |
|---|---|
| public boolean putAll(K key, Iterable<? extends V> values) Adds a mapping to the specified key for all values contained in the given Iterable.
| |
| putAll | back to summary |
|---|---|
| public boolean putAll(Map<? extends K, ? extends V> map) Copies all mappings from the specified map to this multi-valued map (optional operation).
The effect of this call is equivalent to that of calling
The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
| |
| putAll | back to summary |
|---|---|
| public boolean putAll(MultiValuedMap<? extends K, ? extends V> map) Copies all mappings from the specified map to this multi-valued map (optional operation).
The effect of this call is equivalent to that of calling
The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
| |
| remove | back to summary |
|---|---|
| public Collection Removes all values associated with the specified key. The returned collection may be modifiable, but updates will not be propagated to this multi-valued map. In case no mapping was stored for the specified key, an empty, unmodifiable collection will be returned.
| |
| removeMapping | back to summary |
|---|---|
| public boolean removeMapping(Object key, Object item) Removes a key-value mapping from the 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
an empty collection from a subsequent
| |
| size | back to summary |
|---|---|
| public int size() Gets the total size of the map. Implementations would return the total size of the map which is the count of the values from all keys.
| |
| values | back to summary |
|---|---|
| public Collection Gets a Implementations typically return a collection containing the combination of values from all keys.
| |