java.lang.Object
org.pentaho.reporting.libraries.base.util.LinkedMap
All Implemented Interfaces:
Serializable, Cloneable

public class LinkedMap extends Object implements Cloneable, Serializable
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

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static final class 
    A cache map entry class holding both the key and value and acting as member of a linked list.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    LinkedMap(int initialCapacity, float loadFactor)
    Creates a new map with the given initial number of buckets and the given loadfactor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the map and removes all map records.
    Clones this map.
    boolean
    Checks, whether the map contains an entry for the key.
    get(Object key)
    Retrieves the object stored under the given key from the map.
    boolean
    Checks whether this collection is empty.
    Returns the keys used in this map as array.
    keys(Object[] data)
    Returns the keys used in this map as array.
    put(Object key, Object value)
    Stores the given value in the map using the provided key.
    Removes the object stored under the given key from the map.
    int
    Returns the number of entries in the map.
    Returns the values used in this map as array.
    values(Object[] data)
    Returns the values used in this map as array.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public Object put(Object key, Object value)
      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

      public Object get(Object key)
      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

      public Object remove(Object key)
      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

      public boolean containsKey(Object key)
      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

      public Object[] keys(Object[] data)
      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

      public Object[] 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

      public Object[] 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

      public Object[] values(Object[] data)
      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

      public Object clone() throws CloneNotSupportedException
      Clones this map.
      Overrides:
      clone in class Object
      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.