Class ArrayListValuedLinkedHashMap<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.ArrayListValuedLinkedHashMap<K,V>
- Type Parameters:
K- the type of the keys in this mapV- the type of the values in this map
- All Implemented Interfaces:
Serializable,ListValuedMap<K,,V> MultiValuedMap<K,V>
public class ArrayListValuedLinkedHashMap<K,V>
extends AbstractListValuedMap<K,V>
implements Serializable
Implements a
ListValuedMap, using a LinkedHashMap to provide data
storage and ArrayLists as value collections. This is the standard
implementation of a ListValuedMap.
Note that ArrayListValuedLinkedHashMap 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.5.0-M3
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.collections4.multimap.AbstractMultiValuedMap
AbstractMultiValuedMap.WrappedCollection -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe initial list capacity when using none specified in constructor.private static final intThe initial map capacity used when none specified in constructor.private final intThe initial list capacity when creating a new value collection.private static final longSerialization Version -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty ArrayListValuedHashMap with the default initial map capacity (16) and the default initial list capacity (3).ArrayListValuedLinkedHashMap(int initialListCapacity) Creates an empty ArrayListValuedHashMap with the default initial map capacity (16) and the specified initial list capacity.ArrayListValuedLinkedHashMap(int initialMapCapacity, int initialListCapacity) Creates an empty ArrayListValuedHashMap with the specified initial map and list capacities.ArrayListValuedLinkedHashMap(Map<? extends K, ? extends V> map) Creates an ArrayListValuedHashMap copying all the mappings of the given map.ArrayListValuedLinkedHashMap(MultiValuedMap<? extends K, ? extends V> map) Creates an ArrayListValuedHashMap copying all the mappings of the given map. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new value collection using the provided factory.private voidDeserializes an instance from an ObjectInputStream.voidTrims the capacity of all value collections to their current size.private voidSerializes this object to an ObjectOutputStream.Methods inherited from class org.apache.commons.collections4.multimap.AbstractListValuedMap
get, getMap, remove, wrappedCollectionMethods 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, valuesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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 Details
-
serialVersionUID
private static final long serialVersionUIDSerialization Version- See Also:
-
DEFAULT_INITIAL_MAP_CAPACITY
private static final int DEFAULT_INITIAL_MAP_CAPACITYThe initial map capacity used when none specified in constructor.- See Also:
-
DEFAULT_INITIAL_LIST_CAPACITY
private static final int DEFAULT_INITIAL_LIST_CAPACITYThe initial list capacity when using none specified in constructor.- See Also:
-
initialListCapacity
private final int initialListCapacityThe initial list capacity when creating a new value collection.
-
-
Constructor Details
-
ArrayListValuedLinkedHashMap
public ArrayListValuedLinkedHashMap()Creates an empty ArrayListValuedHashMap with the default initial map capacity (16) and the default initial list capacity (3). -
ArrayListValuedLinkedHashMap
public ArrayListValuedLinkedHashMap(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
-
ArrayListValuedLinkedHashMap
public ArrayListValuedLinkedHashMap(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
-
ArrayListValuedLinkedHashMap
Creates an ArrayListValuedHashMap copying all the mappings of the given map.- Parameters:
map- aMapto copy into this map
-
ArrayListValuedLinkedHashMap
Creates an ArrayListValuedHashMap copying all the mappings of the given map.- Parameters:
map- aMultiValuedMapto copy into this map
-
-
Method Details
-
createCollection
Description copied from class:AbstractListValuedMapCreates a new value collection using the provided factory.- Specified by:
createCollectionin classAbstractListValuedMap<K,V> - Returns:
- a new list
-
readObject
Deserializes an instance from an ObjectInputStream.- Parameters:
in- The source ObjectInputStream.- Throws:
IOException- Any of the usual Input/Output related exceptions.ClassNotFoundException- A class of a serialized object cannot be found.
-
trimToSize
public void trimToSize()Trims the capacity of all value collections to their current size. -
writeObject
Serializes this object to an ObjectOutputStream.- Parameters:
out- the target ObjectOutputStream.- Throws:
IOException- thrown when an I/O errors occur writing to the target stream.
-