|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap<K,V> org.apache.commons.collections.map.AbstractHashedMap<K,V> org.apache.commons.collections.map.AbstractLinkedMap<K,V> org.apache.commons.collections.map.LinkedMap<K,V>
public class LinkedMap<K,V>
A Map
implementation that maintains the order of the entries.
In this implementation order is maintained by original insertion.
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.commons.collections.map.AbstractLinkedMap |
---|
AbstractLinkedMap.EntrySetIterator<K,V>, AbstractLinkedMap.KeySetIterator<K,V>, AbstractLinkedMap.LinkEntry<K,V>, AbstractLinkedMap.LinkIterator<K,V>, AbstractLinkedMap.LinkMapIterator<K,V>, AbstractLinkedMap.ValuesIterator<K,V> |
Nested classes/interfaces inherited from class org.apache.commons.collections.map.AbstractHashedMap |
---|
AbstractHashedMap.EntrySet<K,V>, AbstractHashedMap.HashEntry<K,V>, AbstractHashedMap.HashIterator<K,V>, AbstractHashedMap.HashMapIterator<K,V>, AbstractHashedMap.KeySet<K,V>, AbstractHashedMap.Values<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Field Summary |
---|
Fields inherited from class org.apache.commons.collections.map.AbstractLinkedMap |
---|
header |
Fields inherited from class org.apache.commons.collections.map.AbstractHashedMap |
---|
data, DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR, DEFAULT_THRESHOLD, entrySet, GETKEY_INVALID, GETVALUE_INVALID, keySet, loadFactor, MAXIMUM_CAPACITY, modCount, NO_NEXT_ENTRY, NO_PREVIOUS_ENTRY, NULL, REMOVE_INVALID, SETVALUE_INVALID, size, threshold, values |
Constructor Summary | |
---|---|
LinkedMap()
Constructs 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. |
|
LinkedMap(Map<? extends K,? extends V> map)
Constructor copying elements from another map. |
Method Summary | |
---|---|
List<K> |
asList()
Gets an unmodifiable List view of the keys. |
Object |
clone()
Clones the map without cloning the keys or values. |
K |
get(int index)
Gets the key at the specified index. |
V |
getValue(int index)
Gets the value at the specified index. |
int |
indexOf(Object key)
Gets the index of the specified key. |
V |
remove(int index)
Removes the element at the specified index. |
Methods inherited from class org.apache.commons.collections.map.AbstractLinkedMap |
---|
addEntry, clear, containsValue, createEntry, createEntrySetIterator, createKeySetIterator, createValuesIterator, entryAfter, entryBefore, firstKey, getEntry, init, lastKey, mapIterator, nextKey, orderedMapIterator, previousKey, removeEntry |
Methods inherited from class org.apache.commons.collections.map.AbstractHashedMap |
---|
addMapping, calculateNewCapacity, calculateThreshold, checkCapacity, containsKey, destroyEntry, doReadObject, doWriteObject, ensureCapacity, entryHashCode, entryKey, entryNext, entrySet, entryValue, equals, get, getEntry, hash, hashCode, hashIndex, isEmpty, isEqualKey, isEqualValue, keySet, put, putAll, remove, removeMapping, reuseEntry, size, toString, updateEntry, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
containsKey, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Constructor Detail |
---|
public LinkedMap()
public LinkedMap(int initialCapacity)
initialCapacity
- the initial capacity
IllegalArgumentException
- if the initial capacity is less than onepublic LinkedMap(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacityloadFactor
- the load factor
IllegalArgumentException
- if the initial capacity is less than one
IllegalArgumentException
- if the load factor is less than zeropublic LinkedMap(Map<? extends K,? extends V> map)
map
- the map to copy
NullPointerException
- if the map is nullMethod Detail |
---|
public Object clone()
clone
in class AbstractHashedMap<K,V>
public K get(int index)
index
- the index to retrieve
IndexOutOfBoundsException
- if the index is invalidpublic V getValue(int index)
index
- the index to retrieve
IndexOutOfBoundsException
- if the index is invalidpublic int indexOf(Object key)
key
- the key to find the index of
public V remove(int index)
index
- the index of the object to remove
key
,
or null
if none existed
IndexOutOfBoundsException
- if the index is invalidpublic List<K> asList()
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()
.
AbstractHashedMap.keySet()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |