Class AbstractLinkedMap<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:
- Map<K,,- V> - Get<K,,- V> - IterableGet<K,,- V> - IterableMap<K,,- V> - OrderedMap<K,,- V> - Put<K,- V> 
 This class implements all the features necessary for a subclass linked
 hash-based map. Key-value entries are stored in instances of the
 LinkEntry class which can be overridden and replaced.
 The iterators can similarly be replaced, without the need to replace the KeySet,
 EntrySet and Values view classes.
 
Overridable methods are provided to change the default hashing behavior, and to change how entries are added to and removed from the map. Hopefully, all you need for unusual subclasses is here.
 This implementation maintains order by original insertion, but subclasses
 may work differently. The OrderedMap interface is implemented
 to provide access to bidirectional iteration and extra convenience methods.
 
 The orderedMapIterator() method provides direct access to a
 bidirectional iterator. The iterators from the other views can also be cast
 to OrderedIterator if required.
 
 All the available iterators can be reset back to the start by casting to
 ResettableIterator and calling reset().
 
The implementation is also designed to be subclassed, with lots of useful methods exposed.
- Since:
- 3.0
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classEntrySet iterator.protected static classKeySet iterator.protected static classLinkEntry that stores the data.protected static classBase Iterator that iterates in link order.protected static classMapIterator implementation.protected static classValues iterator.Nested classes/interfaces inherited from class org.apache.commons.collections4.map.AbstractHashedMapAbstractHashedMap.EntrySet<K,V>, AbstractHashedMap.HashEntry<K, V>, AbstractHashedMap.HashIterator<K, V>, AbstractHashedMap.HashMapIterator<K, V>, AbstractHashedMap.KeySet<K>, AbstractHashedMap.Values<V> Nested classes/interfaces inherited from class java.util.AbstractMapAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> 
- 
Field SummaryFields inherited from class org.apache.commons.collections4.map.AbstractHashedMapDEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_THRESHOLD, GETKEY_INVALID, GETVALUE_INVALID, MAXIMUM_CAPACITY, NO_NEXT_ENTRY, NO_PREVIOUS_ENTRY, NULL, REMOVE_INVALID, SETVALUE_INVALID
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedConstructor only used in deserialization, do not use otherwise.protectedAbstractLinkedMap(int initialCapacity) Constructs a new, empty map with the specified initial capacity.protectedAbstractLinkedMap(int initialCapacity, float loadFactor) Constructs a new, empty map with the specified initial capacity and load factor.protectedAbstractLinkedMap(int initialCapacity, float loadFactor, int threshold) Constructor which performs no validation on the passed in parameters.protectedAbstractLinkedMap(Map<? extends K, ? extends V> map) Constructor copying elements from another map.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddEntry(AbstractHashedMap.HashEntry<K, V> entry, int hashIndex) Adds an entry into this map, maintaining insertion order.voidclear()Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues.booleancontainsValue(Object value) Checks whether the map contains the specified value.protected AbstractLinkedMap.LinkEntry<K, V> createEntry(AbstractHashedMap.HashEntry<K, V> next, int hashCode, K key, V value) Creates an entry to store the data.Creates an entry set iterator.Creates a key set iterator.Creates a values iterator.protected AbstractLinkedMap.LinkEntry<K, V> entryAfter(AbstractLinkedMap.LinkEntry<K, V> entry) Gets theafterfield from aLinkEntry.protected AbstractLinkedMap.LinkEntry<K, V> entryBefore(AbstractLinkedMap.LinkEntry<K, V> entry) Gets thebeforefield from aLinkEntry.firstKey()Gets the first key in the map, which is the first inserted.protected AbstractLinkedMap.LinkEntry<K, V> getEntry(int index) Gets the key at the specified index.protected AbstractLinkedMap.LinkEntry<K, V> Gets the entry mapped to the key specified.protected voidinit()Initialize this subclass during construction.lastKey()Gets the last key in the map, which is the most recently inserted.Gets an iterator over the map.Gets the next key in sequence.previousKey(Object key) Gets the previous key in sequence.protected voidremoveEntry(AbstractHashedMap.HashEntry<K, V> entry, int hashIndex, AbstractHashedMap.HashEntry<K, V> previous) Removes an entry from the map and the linked list.Methods inherited from class org.apache.commons.collections4.map.AbstractHashedMapaddMapping, calculateNewCapacity, calculateThreshold, checkCapacity, clone, containsKey, convertKey, destroyEntry, doReadObject, doWriteObject, ensureCapacity, entryHashCode, entryKey, entryNext, entrySet, entryValue, equals, get, hash, hashCode, hashIndex, isEmpty, isEqualKey, isEqualValue, keySet, put, putAll, remove, removeMapping, reuseEntry, size, toString, updateEntry, valuesMethods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.collections4.GetcontainsKey, entrySet, get, isEmpty, keySet, remove, size, valuesMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, containsKey, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
- 
Constructor Details- 
AbstractLinkedMapprotected AbstractLinkedMap()Constructor only used in deserialization, do not use otherwise.
- 
AbstractLinkedMapConstructs a new, empty map with the specified initial capacity.- Parameters:
- initialCapacity- the initial capacity
- Throws:
- IllegalArgumentException- if the initial capacity is negative
 
- 
AbstractLinkedMapConstructs a new, empty map with the specified initial capacity and load factor.- Parameters:
- initialCapacity- the initial capacity
- loadFactor- the load factor
- Throws:
- IllegalArgumentException- if the initial capacity is negative
- IllegalArgumentException- if the load factor is less than zero
 
- 
AbstractLinkedMapConstructor which performs no validation on the passed in parameters.- Parameters:
- initialCapacity- the initial capacity, must be a power of two
- loadFactor- the load factor, must be > 0.0f and generally < 1.0f
- threshold- the threshold, must be sensible
 
- 
AbstractLinkedMapConstructor copying elements from another map.- Parameters:
- map- the map to copy
- Throws:
- NullPointerException- if the map is null
 
 
- 
- 
Method Details- 
addEntryAdds an entry into this map, maintaining insertion order.This implementation adds the entry to the data storage table and to the end of the linked list. - Overrides:
- addEntryin class- AbstractHashedMap<K,- V> 
- Parameters:
- entry- the entry to add
- hashIndex- the index into the data array to store at
 
- 
clear
- 
containsValueChecks whether the map contains the specified value.- Specified by:
- containsValuein interface- Get<K,- V> 
- Specified by:
- containsValuein interface- Map<K,- V> 
- Overrides:
- containsValuein class- AbstractHashedMap<K,- V> 
- Parameters:
- value- the value to search for
- Returns:
- true if the map contains the value
- See Also:
 
- 
createEntryprotected AbstractLinkedMap.LinkEntry<K,V> createEntry(AbstractHashedMap.HashEntry<K, V> next, int hashCode, K key, V value) Creates an entry to store the data.This implementation creates a new LinkEntry instance. - Overrides:
- createEntryin class- AbstractHashedMap<K,- V> 
- Parameters:
- next- the next entry in sequence
- hashCode- the hash code to use
- key- the key to store
- value- the value to store
- Returns:
- the newly created entry
 
- 
createEntrySetIteratorCreates an entry set iterator. Subclasses can override this to return iterators with different properties.- Overrides:
- createEntrySetIteratorin class- AbstractHashedMap<K,- V> 
- Returns:
- the entrySet iterator
 
- 
createKeySetIteratorCreates a key set iterator. Subclasses can override this to return iterators with different properties.- Overrides:
- createKeySetIteratorin class- AbstractHashedMap<K,- V> 
- Returns:
- the keySet iterator
 
- 
createValuesIteratorCreates a values iterator. Subclasses can override this to return iterators with different properties.- Overrides:
- createValuesIteratorin class- AbstractHashedMap<K,- V> 
- Returns:
- the values iterator
 
- 
entryAfterGets theafterfield from aLinkEntry. Used in subclasses that have no visibility of the field.- Parameters:
- entry- the entry to query, must not be null
- Returns:
- the afterfield of the entry
- Throws:
- NullPointerException- if the entry is null
- Since:
- 3.1
 
- 
entryBeforeGets thebeforefield from aLinkEntry. Used in subclasses that have no visibility of the field.- Parameters:
- entry- the entry to query, must not be null
- Returns:
- the beforefield of the entry
- Throws:
- NullPointerException- if the entry is null
- Since:
- 3.1
 
- 
firstKey
- 
getEntryGets the key at the specified index.- Parameters:
- index- the index to retrieve
- Returns:
- the key at the specified index
- Throws:
- IndexOutOfBoundsException- if the index is invalid
 
- 
getEntryDescription copied from class:AbstractHashedMapGets the entry mapped to the key specified.This method exists for subclasses that may need to perform a multi-step process accessing the entry. The public methods in this class don't use this method to gain a small performance boost. - Overrides:
- getEntryin class- AbstractHashedMap<K,- V> 
- Parameters:
- key- the key
- Returns:
- the entry, null if no match
 
- 
initInitialize this subclass during construction.Note: As from v3.2 this method calls createEntry(HashEntry, int, Object, Object)to create the map entry object.- Overrides:
- initin class- AbstractHashedMap<K,- V> 
 
- 
lastKey
- 
mapIteratorGets an iterator over the map. Changes made to the iterator affect this map.A MapIterator returns the keys in the map. It also provides convenient methods to get the key and value, and set the value. It avoids the need to create an entrySet/keySet/values object. It also avoids creating the Map.Entry object. - Specified by:
- mapIteratorin interface- IterableGet<K,- V> 
- Specified by:
- mapIteratorin interface- OrderedMap<K,- V> 
- Overrides:
- mapIteratorin class- AbstractHashedMap<K,- V> 
- Returns:
- the map iterator
 
- 
nextKey
- 
previousKeyGets the previous key in sequence.- Specified by:
- previousKeyin interface- OrderedMap<K,- V> 
- Parameters:
- key- the key to get before
- Returns:
- the previous key
 
- 
removeEntryprotected void removeEntry(AbstractHashedMap.HashEntry<K, V> entry, int hashIndex, AbstractHashedMap.HashEntry<K, V> previous) Removes an entry from the map and the linked list.This implementation removes the entry from the linked list chain, then calls the superclass implementation. - Overrides:
- removeEntryin class- AbstractHashedMap<K,- V> 
- Parameters:
- entry- the entry to remove
- hashIndex- the index into the data structure
- previous- the previous entry in the chain
 
 
-