Class WeakValueHashMap

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
org.processmining.framework.util.WeakValueHashMap
All Implemented Interfaces:
Serializable, Cloneable, Map

public class WeakValueHashMap extends HashMap
A WeakValueHashMap is implemented as a HashMap that maps keys to WeakValues. Because we don't have access to the innards of the HashMap, we have to wrap/unwrap value objects with WeakValues on every operation. Fortunately WeakValues are small, short-lived objects, so the added allocation overhead is tolerable. This implementaton directly extends java.util.HashMap.
Author:
Markus Fuchs
See Also:
  • Constructor Details

    • WeakValueHashMap

      public WeakValueHashMap()
  • Method Details

    • size

      public int size()
      Returns the number of key-value mappings in this map.

      Specified by:
      size in interface Map
      Overrides:
      size in class HashMap
      Returns:
      the number of key-value mappings in this map.
    • isEmpty

      public boolean isEmpty()
      Returns true if this map contains no key-value mappings.

      Specified by:
      isEmpty in interface Map
      Overrides:
      isEmpty in class HashMap
      Returns:
      true if this map contains no key-value mappings.
    • containsKey

      public boolean containsKey(Object key)
      Returns true if this map contains a mapping for the specified key.

      Specified by:
      containsKey in interface Map
      Overrides:
      containsKey in class HashMap
      Parameters:
      key - key whose presence in this map is to be tested
      Returns:
      true if this map contains a mapping for the specified key.
    • containsValue

      public boolean containsValue(Object value)
      Returns true if this map maps one or more keys to the specified value.

      Specified by:
      containsValue in interface Map
      Overrides:
      containsValue in class HashMap
      Parameters:
      value - value whose presence in this map is to be tested
      Returns:
      true if this map maps one or more keys to this value.
    • get

      public Object get(Object key)
      Gets the value for the given key.

      Specified by:
      get in interface Map
      Overrides:
      get in class HashMap
      Parameters:
      key - key whose associated value, if any, is to be returned
      Returns:
      the value to which this map maps the specified key.
    • put

      public Object put(Object key, Object value)
      Puts a new (key,value) into the map.

      Specified by:
      put in interface Map
      Overrides:
      put in class HashMap
      Parameters:
      key - key with which the specified value is to be associated.
      value - value to be associated with the specified key.
      Returns:
      previous value associated with specified key, or null if there was no mapping for key or the value has been garbage collected by the garbage collector.
    • remove

      public Object remove(Object key)
      Removes key and value for the given key.

      Specified by:
      remove in interface Map
      Overrides:
      remove in class HashMap
      Parameters:
      key - key whose mapping is to be removed from the map.
      Returns:
      previous value associated with specified key, or null if there was no mapping for key or the value has been garbage collected by the garbage collector.
    • entrySet

      public Set entrySet()
      Returns a Set view of the mappings in this map.

      Specified by:
      entrySet in interface Map
      Overrides:
      entrySet in class HashMap
      Returns:
      a Set view of the mappings in this map.
    • values

      public Collection values()
      Returns a Collection view of the values contained in this map.

      Specified by:
      values in interface Map
      Overrides:
      values in class HashMap
      Returns:
      a Collection view of the values contained in this map.