Package org.apache.commons.collections4.multimap

# Class ArrayListValuedHashMap<K,V>

java.lang.Object
org.apache.commons.collections4.multimap.AbstractMultiValuedMap<K,V>
org.apache.commons.collections4.multimap.AbstractListValuedMap<K,V>
org.apache.commons.collections4.multimap.ArrayListValuedHashMap<K,V>

Type Parameters:
  `K` - The type of the keys in this map
  `V` - The type of the values in this map

All Implemented Interfaces:
  `Serializable`, `ListValuedMap<K,V>`, `MultiValuedMap<K,V>`

public class ArrayListValuedHashMap<K,V> extends AbstractListValuedMap<K,V> implements Serializable
Implements a `ListValuedMap`, using a `HashMap` to provide data storage and `ArrayList`s as value collections. This is the standard implementation of a ListValuedMap.

Note that ArrayListValuedHashMap is not synchronized and is not thread-safe. If you wish to use this map from multiple threads concurrently, you must use appropriate synchronization. This class may throw exceptions when accessed by concurrent threads without synchronization.

Since:
  4.1
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ArrayListValuedHashMap()`
  Creates an empty ArrayListValuedHashMap with the default initial map capacity (16) and the default initial list capacity (3).
  `ArrayListValuedHashMap(int initialListCapacity)`
  Creates an empty ArrayListValuedHashMap with the default initial map capacity (16) and the specified initial list capacity.
  `ArrayListValuedHashMap(int initialMapCapacity, int initialListCapacity)`
  Creates an empty ArrayListValuedHashMap with the specified initial map and list capacities.
  `ArrayListValuedHashMap(Map<? extends K,? extends V> map)`
  Creates an ArrayListValuedHashMap copying all the mappings of the given map.
  `ArrayListValuedHashMap(MultiValuedMap<? extends K,? extends V> map)`
  Creates an ArrayListValuedHashMap copying all the mappings of the given map.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected ArrayList<V>`
  `createCollection()`
  Creates a new value collection using the provided factory.
  `ArrayListValuedHashMap<V,K>`
  `inverted()`
  Always throws `UnsupportedOperationException`.
  `void`
  `trimToSize()`
  Trims the capacity of all value collections to their current size.

  ### Methods inherited from class org.apache.commons.collections4.multimap.AbstractListValuedMap

  `get, getMap, remove`

  ### Methods inherited from class org.apache.commons.collections4.multimap.AbstractMultiValuedMap

  `asMap, clear, containsKey, containsMapping, containsValue, doReadObject, doWriteObject, entries, equals, hashCode, isEmpty, keys, keySet, mapIterator, put, putAll, putAll, putAll, removeMapping, setMap, size, toString, values`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.apache.commons.collections4.MultiValuedMap

  `asMap, clear, containsKey, containsMapping, containsValue, entries, isEmpty, keys, keySet, mapIterator, put, putAll, putAll, putAll, removeMapping, size, values`

- ## Constructor Details

  - ### ArrayListValuedHashMap

    public ArrayListValuedHashMap()
    Creates an empty ArrayListValuedHashMap with the default initial map capacity (16) and the default initial list capacity (3).

  - ### ArrayListValuedHashMap

    public ArrayListValuedHashMap(int initialListCapacity)
    Creates an empty ArrayListValuedHashMap with the default initial map capacity (16) and the specified initial list capacity.
    Parameters:
      `initialListCapacity` - The initial capacity used for value collections

  - ### ArrayListValuedHashMap

    public ArrayListValuedHashMap(int initialMapCapacity, int initialListCapacity)
    Creates an empty ArrayListValuedHashMap with the specified initial map and list capacities.
    Parameters:
      `initialMapCapacity` - The initial hashmap capacity
      `initialListCapacity` - The initial capacity used for value collections

  - ### ArrayListValuedHashMap

    public ArrayListValuedHashMap(Map<? extends K,? extends V> map)
    Creates an ArrayListValuedHashMap copying all the mappings of the given map.
    Parameters:
      `map` - A `Map` to copy into this map

  - ### ArrayListValuedHashMap

    public ArrayListValuedHashMap(MultiValuedMap<? extends K,? extends V> map)
    Creates an ArrayListValuedHashMap copying all the mappings of the given map.
    Parameters:
      `map` - A `MultiValuedMap` to copy into this map

- ## Method Details

  - ### createCollection

    protected ArrayList<V> createCollection()
    Description copied from class: `AbstractListValuedMap`
    Creates a new value collection using the provided factory.
    Specified by:
      `createCollection` in class `AbstractListValuedMap<K,V>`
    Returns:
      A new list

  - ### inverted

    public ArrayListValuedHashMap<V,K> inverted()
    Description copied from interface: `MultiValuedMap`
    Always throws `UnsupportedOperationException`.
    Specified by:
      `inverted` in interface `MultiValuedMap<K,V>`
    Returns:
      Always throws `UnsupportedOperationException`.

  - ### trimToSize

    public void trimToSize()
    Trims the capacity of all value collections to their current size.