java.lang.Object | ||||
↳ | java.util.AbstractMap<K, V> | |||
↳ | org.apache.commons.collections.map.AbstractHashedMap | |||
↳ | org.apache.commons.collections.map.AbstractLinkedMap | |||
↳ | org.apache.commons.collections.map.LinkedMap |
A 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 synchronizedMap(Map)
. This class may throw
exceptions when accessed by concurrent threads without synchronization.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.map.AbstractHashedMap
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.map.AbstractLinkedMap
| |||||||||||
From class
org.apache.commons.collections.map.AbstractHashedMap
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new empty map with default size and load factor.
| |||||||||||
Constructs a new, empty map with the specified initial capacity.
| |||||||||||
Constructs a new, empty map with the specified initial capacity and
load factor.
| |||||||||||
Constructor copying elements from another map.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets an unmodifiable List view of the keys.
| |||||||||||
Clones the map without cloning the keys or values.
| |||||||||||
Gets the key at the specified index.
| |||||||||||
Gets the value at the specified index.
| |||||||||||
Gets the index of the specified key.
| |||||||||||
Removes the element at the specified index.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.map.AbstractLinkedMap
| |||||||||||
From class
org.apache.commons.collections.map.AbstractHashedMap
| |||||||||||
From class
java.util.AbstractMap
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.util.Map
| |||||||||||
From interface
org.apache.commons.collections.IterableMap
| |||||||||||
From interface
org.apache.commons.collections.OrderedMap
|
Constructs a new empty map with default size and load factor.
Constructs a new, empty map with the specified initial capacity.
initialCapacity | the initial capacity |
---|
IllegalArgumentException | if the initial capacity is less than one |
---|
Constructs a new, empty map with the specified initial capacity and load factor.
initialCapacity | the initial capacity |
---|---|
loadFactor | the load factor |
IllegalArgumentException | if the initial capacity is less than one |
---|---|
IllegalArgumentException | if the load factor is less than zero |
Constructor copying elements from another map.
map | the map to copy |
---|
NullPointerException | if the map is null |
---|
Gets an unmodifiable List view of the keys.
The returned list is unmodifiable because changes to the values of
the list (using 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 keySet()
.
Gets the key at the specified index.
index | the index to retrieve |
---|
IndexOutOfBoundsException | if the index is invalid |
---|
Gets the value at the specified index.
index | the index to retrieve |
---|
IndexOutOfBoundsException | if the index is invalid |
---|
Gets the index of the specified key.
key | the key to find the index of |
---|
Removes the element at the specified index.
index | the index of the object to remove |
---|
key
,
or null
if none existedIndexOutOfBoundsException | if the index is invalid |
---|