Class LinkedMap<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,- Cloneable,- Map<K,,- V> - Get<K,,- V> - IterableGet<K,,- V> - IterableMap<K,,- V> - OrderedMap<K,,- V> - Put<K,- V> 
Map implementation that maintains the order of the entries.
 In this implementation order is maintained by original insertion.
 
 This implementation improves on the JDK1.4 LinkedHashMap by adding the
 MapIterator
 functionality, additional convenience methods and allowing
 bidirectional iteration. It also implements OrderedMap.
 In addition, non-interface methods are provided to access the map by index.
 
 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.
 Note that LinkedMap is not synchronized and is not thread-safe.
 If you wish to use this map from multiple threads concurrently, you must use
 appropriate synchronization. The simplest approach is to wrap this map
 using Collections.synchronizedMap(Map). This class may throw
 exceptions when accessed by concurrent threads without synchronization.
 
- Since:
- 3.0
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class org.apache.commons.collections4.map.AbstractLinkedMapAbstractLinkedMap.EntrySetIterator<K,V>, AbstractLinkedMap.KeySetIterator<K>, AbstractLinkedMap.LinkEntry<K, V>, AbstractLinkedMap.LinkIterator<K, V>, AbstractLinkedMap.LinkMapIterator<K, V>, AbstractLinkedMap.ValuesIterator<V> 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 SummaryConstructorsConstructorDescriptionConstructs a new empty map with default size and load factor.LinkedMap(int initialCapacity) Constructs a new, empty map with the specified initial capacity.LinkedMap(int initialCapacity, float loadFactor) Constructs a new, empty map with the specified initial capacity and load factor.Constructor copying elements from another map.
- 
Method SummaryModifier and TypeMethodDescriptionasList()Gets an unmodifiable List view of the keys.clone()Clones the map without cloning the keys or values.get(int index) Gets the key at the specified index.getValue(int index) Gets the value at the specified index.intGets the index of the specified key.remove(int index) Removes the element at the specified index.Methods inherited from class org.apache.commons.collections4.map.AbstractLinkedMapaddEntry, clear, containsValue, createEntry, createEntrySetIterator, createKeySetIterator, createValuesIterator, entryAfter, entryBefore, firstKey, getEntry, getEntry, init, lastKey, mapIterator, nextKey, previousKey, removeEntryMethods inherited from class org.apache.commons.collections4.map.AbstractHashedMapaddMapping, calculateNewCapacity, calculateThreshold, checkCapacity, 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- 
LinkedMappublic LinkedMap()Constructs a new empty map with default size and load factor.
- 
LinkedMapConstructs a new, empty map with the specified initial capacity.- Parameters:
- initialCapacity- the initial capacity
- Throws:
- IllegalArgumentException- if the initial capacity is negative
 
- 
LinkedMapConstructs 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
 
- 
LinkedMapConstructor copying elements from another map.- Parameters:
- map- the map to copy
- Throws:
- NullPointerException- if the map is null
 
 
- 
- 
Method Details- 
asListGets an unmodifiable List view of the keys.The returned list is unmodifiable because changes to the values of the list (using ListIterator.set(Object)) will effectively remove the value from the list and reinsert that value at the end of the list, which is an unexpected side effect of changing the value of a list. This occurs because changing the key, changes when the mapping is added to the map and thus where it appears in the list.An alternative to this method is to use AbstractHashedMap.keySet().- Returns:
- The ordered list of keys.
- See Also:
 
- 
clone
- 
getGets 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
 
- 
getValueGets the value at the specified index.- Parameters:
- index- the index to retrieve
- Returns:
- the value at the specified index
- Throws:
- IndexOutOfBoundsException- if the index is invalid
 
- 
indexOf
- 
removeRemoves the element at the specified index.- Parameters:
- index- the index of the object to remove
- Returns:
- the previous value corresponding the key, ornullif none existed
- Throws:
- IndexOutOfBoundsException- if the index is invalid
 
 
-