public class WeakValueMap extends ReferenceValueMap
java.util.Map
implementation using weak reference values.
The values are stored in the map as weak references. If the garbage collector clears the reference, the corresponding key is automatically removed from the map.
WeakReference
ReferenceValueMap.ValueReference
Constructor and Description |
---|
WeakValueMap()
Default Constructor
|
WeakValueMap(int initialCapacity)
Constructor taking the initial capacity.
|
WeakValueMap(int initialCapacity,
float loadFactor)
Constructor taking the initial capacity and load factor.
|
WeakValueMap(Map m)
Constructor taking a Map for definition.
|
Modifier and Type | Method and Description |
---|---|
protected ReferenceValueMap.ValueReference |
newValueReference(Object key,
Object value,
ReferenceQueue queue)
Returns a new
Reference object to be inserted into the map. |
clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, reap, remove, size, values
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public WeakValueMap()
public WeakValueMap(int initialCapacity)
initialCapacity
- The Initial capacity of the collectionpublic WeakValueMap(int initialCapacity, float loadFactor)
initialCapacity
- The Initial capacity of the collectionloadFactor
- The Load Factor of the collectionpublic WeakValueMap(Map m)
m
- The Mapprotected ReferenceValueMap.ValueReference newValueReference(Object key, Object value, ReferenceQueue queue)
ReferenceValueMap
Reference
object to be inserted into the map.
Subclasses must implement this method to construct Reference
objects of the desired type (e.g. SoftReference
, etc.).newValueReference
in class ReferenceValueMap
key
- The key that will be inserted.value
- The associated value to be referenced.queue
- The ReferenceQueue
with which to register the
new Reference
object.Copyright © 2017. All rights reserved.