Class WeakValueHashMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
com.sun.jdo.spi.persistence.utility.WeakValueHashMap
- All Implemented Interfaces:
Serializable,Cloneable,Map
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Object key) Returns true if this map contains a mapping for the specified key.booleancontainsValue(Object value) Returns true if this map maps one or more keys to the specified value.entrySet()Returns aSetview of the mappings in this map.Gets the value for the given key.booleanisEmpty()Returns true if this map contains no key-value mappings.Puts a new (key,value) into the map.Removes key and value for the given key.intsize()Returns the number of key-value mappings in this map.values()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, replaceAllMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
WeakValueHashMap
public WeakValueHashMap()
-
-
Method Details
-
size
public int size()Returns the number of key-value mappings in this map. -
isEmpty
public boolean isEmpty()Returns true if this map contains no key-value mappings. -
containsKey
Returns true if this map contains a mapping for the specified key.- Specified by:
containsKeyin interfaceMap- Overrides:
containsKeyin classHashMap- 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
Returns true if this map maps one or more keys to the specified value.- Specified by:
containsValuein interfaceMap- Overrides:
containsValuein classHashMap- 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
Gets the value for the given key. -
put
Puts a new (key,value) into the map.- Specified by:
putin interfaceMap- Overrides:
putin classHashMap- 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
Removes key and value for the given key.- Specified by:
removein interfaceMap- Overrides:
removein classHashMap- 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
Returns aSetview of the mappings in this map. -
values
Returns aCollectionview of the values contained in this map.
-