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 mapV
- the type of the values in this map
- All Implemented Interfaces:
java.io.Serializable
,ListValuedMap<K,V>
,MultiValuedMap<K,V>
public class ArrayListValuedHashMap<K,V> extends AbstractListValuedMap<K,V> implements java.io.Serializable
Implements aListValuedMap
, using aHashMap
to provide data storage andArrayList
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.collections4.multimap.AbstractMultiValuedMap
AbstractMultiValuedMap.WrappedCollection
-
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_INITIAL_LIST_CAPACITY
The initial list capacity when using none specified in constructor.private static int
DEFAULT_INITIAL_MAP_CAPACITY
The initial map capacity used when none specified in constructor.private int
initialListCapacity
The initial list capacity when creating a new value collection.private static long
serialVersionUID
Serialization Version
-
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(java.util.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.ArrayList<V>
createCollection()
Creates a new value collection using the provided factory.private void
readObject(java.io.ObjectInputStream ois)
void
trimToSize()
Trims the capacity of all value collections to their current size.private void
writeObject(java.io.ObjectOutputStream oos)
-
Methods inherited from class org.apache.commons.collections4.multimap.AbstractListValuedMap
get, getMap, remove, wrappedCollection
-
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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serialization Version- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_MAP_CAPACITY
private static final int DEFAULT_INITIAL_MAP_CAPACITY
The initial map capacity used when none specified in constructor.- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_LIST_CAPACITY
private static final int DEFAULT_INITIAL_LIST_CAPACITY
The initial list capacity when using none specified in constructor.- See Also:
- Constant Field Values
-
initialListCapacity
private final int initialListCapacity
The initial list capacity when creating a new value collection.
-
-
Constructor Detail
-
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 capacityinitialListCapacity
- the initial capacity used for value collections
-
ArrayListValuedHashMap
public ArrayListValuedHashMap(MultiValuedMap<? extends K,? extends V> map)
Creates an ArrayListValuedHashMap copying all the mappings of the given map.- Parameters:
map
- aMultiValuedMap
to copy into this map
-
-
Method Detail
-
createCollection
protected java.util.ArrayList<V> createCollection()
Description copied from class:AbstractListValuedMap
Creates a new value collection using the provided factory.- Specified by:
createCollection
in classAbstractListValuedMap<K,V>
- Returns:
- a new list
-
trimToSize
public void trimToSize()
Trims the capacity of all value collections to their current size.
-
writeObject
private void writeObject(java.io.ObjectOutputStream oos) throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream ois) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-