Class LinkedMap
java.lang.Object
org.pentaho.reporting.libraries.base.util.LinkedMap
- All Implemented Interfaces:
Serializable
,Cloneable
A fast linked-hashmap that avoids any unneccessay work. It is slightly slower than an ordinary hashmap but faster
than a combined hashmap and list-index that would be needed to get this functionality on JDK 1.2. The map is as fast
as the LinkedHashMap of JDK 1.4+.
- Author:
- Thomas Morgner
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final class
A cache map entry class holding both the key and value and acting as member of a linked list. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the map and removes all map records.clone()
Clones this map.boolean
containsKey
(Object key) Checks, whether the map contains an entry for the key.Retrieves the object stored under the given key from the map.boolean
isEmpty()
Checks whether this collection is empty.Object[]
keys()
Returns the keys used in this map as array.Object[]
Returns the keys used in this map as array.Stores the given value in the map using the provided key.Removes the object stored under the given key from the map.int
size()
Returns the number of entries in the map.Object[]
values()
Returns the values used in this map as array.Object[]
Returns the values used in this map as array.
-
Constructor Details
-
LinkedMap
public LinkedMap()Default constructor. Creates a map for 16 entries with a default load-factor of 0.75. -
LinkedMap
public LinkedMap(int initialCapacity, float loadFactor) Creates a new map with the given initial number of buckets and the given loadfactor. A load factor greater 1 will always cause hash-collisions, while lower loadfactors reduce the likelyhood of collisions.- Parameters:
initialCapacity
- the initial capacity.loadFactor
- the load factor of the bucket-array.
-
-
Method Details
-
size
public int size()Returns the number of entries in the map.- Returns:
- the number of entries.
-
put
Stores the given value in the map using the provided key. Both key and value can be null.- Parameters:
key
- the key.value
- the value to be stored under the key.- Returns:
- the previous value stored under this key or null of the entry is new.
-
get
Retrieves the object stored under the given key from the map.- Parameters:
key
- the key for which a value should be located.- Returns:
- the value or null, if the map did not contain a value for the key.
-
remove
Removes the object stored under the given key from the map.- Parameters:
key
- the key for which a value should be located.- Returns:
- the value or null, if the map did not contain a value for the key.
-
containsKey
Checks, whether the map contains an entry for the key.- Parameters:
key
- the key for which a value should be located.- Returns:
- true if the map contains a value for the key, false otherwise.
-
keys
Returns the keys used in this map as array. The keys are returned in the insertation order.- Parameters:
data
- the object array that should receive the keys.- Returns:
- the array filled with the keys.
-
keys
Returns the keys used in this map as array. The keys are returned in the insertation order.- Returns:
- the array filled with the keys.
-
values
Returns the values used in this map as array. The values are returned in the insertation order.- Returns:
- the array filled with the values.
-
values
Returns the values used in this map as array. The values are returned in the insertation order.- Parameters:
data
- the object array that should receive the values.- Returns:
- the array filled with the values.
-
clear
public void clear()Clears the map and removes all map records. -
clone
Clones this map.- Overrides:
clone
in classObject
- Returns:
- the cloned map.
- Throws:
CloneNotSupportedException
-
isEmpty
public boolean isEmpty()Checks whether this collection is empty.- Returns:
- true, if the collection is empty, false otherwise.
-