Package org.processmining.framework.util
Class WeakValueHashMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap
-
- org.processmining.framework.util.WeakValueHashMap
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map
public class WeakValueHashMap extends java.util.HashMapA 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:
HashMap,WeakReference, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WeakValueHashMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(java.lang.Object key)Returns true if this map contains a mapping for the specified key.booleancontainsValue(java.lang.Object value)Returns true if this map maps one or more keys to the specified value.java.util.SetentrySet()Returns aSetview of the mappings in this map.java.lang.Objectget(java.lang.Object key)Gets the value for the given key.booleanisEmpty()Returns true if this map contains no key-value mappings.java.lang.Objectput(java.lang.Object key, java.lang.Object value)Puts a new (key,value) into the map.java.lang.Objectremove(java.lang.Object key)Removes key and value for the given key.intsize()Returns the number of key-value mappings in this map.java.util.Collectionvalues()Returns aCollectionview of the values contained in this map.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
size
public int size()
Returns the number of key-value mappings in this map.- Specified by:
sizein interfacejava.util.Map- Overrides:
sizein classjava.util.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:
isEmptyin interfacejava.util.Map- Overrides:
isEmptyin classjava.util.HashMap- Returns:
- true if this map contains no key-value mappings.
-
containsKey
public boolean containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified key.- Specified by:
containsKeyin interfacejava.util.Map- Overrides:
containsKeyin classjava.util.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(java.lang.Object value)
Returns true if this map maps one or more keys to the specified value.- Specified by:
containsValuein interfacejava.util.Map- Overrides:
containsValuein classjava.util.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 java.lang.Object get(java.lang.Object key)
Gets the value for the given key.- Specified by:
getin interfacejava.util.Map- Overrides:
getin classjava.util.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 java.lang.Object put(java.lang.Object key, java.lang.Object value)Puts a new (key,value) into the map.- Specified by:
putin interfacejava.util.Map- Overrides:
putin classjava.util.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 java.lang.Object remove(java.lang.Object key)
Removes key and value for the given key.- Specified by:
removein interfacejava.util.Map- Overrides:
removein classjava.util.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 java.util.Set entrySet()
Returns aSetview of the mappings in this map.- Specified by:
entrySetin interfacejava.util.Map- Overrides:
entrySetin classjava.util.HashMap- Returns:
- a
Setview of the mappings in this map.
-
values
public java.util.Collection values()
Returns aCollectionview of the values contained in this map.- Specified by:
valuesin interfacejava.util.Map- Overrides:
valuesin classjava.util.HashMap- Returns:
- a
Collectionview of the values contained in this map.
-
-