Package org.infinispan.commons.util
Class WeakValueHashMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.infinispan.commons.util.WeakValueHashMap<K,V>
-
- Type Parameters:
K
- the key typeV
- the value type
- All Implemented Interfaces:
Map<K,V>
public final class WeakValueHashMap<K,V> extends AbstractMap<K,V>
This Map will remove entries when the value in the map has been cleaned from garbage collection- Author:
- Bill Burke, Adrian Brock, Ales Justin
- See Also:
- JBoss Common Core source code for origins of this class
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
WeakValueHashMap.ValueRef<K,V>
-
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 Constructor Description WeakValueHashMap()
Constructs a new, emptyWeakValueHashMap
with the default initial capacity and the default load factor, which is0.75
.WeakValueHashMap(int initialCapacity)
Constructs a new, emptyWeakValueHashMap
with the given initial capacity and the default load factor, which is0.75
.WeakValueHashMap(int initialCapacity, float loadFactor)
Constructs a new, emptyWeakValueHashMap
with the given initial capacity and the given load factor.WeakValueHashMap(Map<K,V> t)
Constructs a newWeakValueHashMap
with the same mappings as the specified Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
protected Map<K,WeakValueHashMap.ValueRef<K,V>>
createMap()
Create map.Set<Map.Entry<K,V>>
entrySet()
V
get(Object key)
V
put(K key, V value)
V
remove(Object key)
int
size()
String
toString()
-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
WeakValueHashMap
public WeakValueHashMap(int initialCapacity, float loadFactor)
Constructs a new, emptyWeakValueHashMap
with the given initial capacity and the given load factor.- Parameters:
initialCapacity
- The initial capacity of theWeakValueHashMap
loadFactor
- The load factor of theWeakValueHashMap
- Throws:
IllegalArgumentException
- If the initial capacity is less than zero, or if the load factor is nonpositive
-
WeakValueHashMap
public WeakValueHashMap(int initialCapacity)
Constructs a new, emptyWeakValueHashMap
with the given initial capacity and the default load factor, which is0.75
.- Parameters:
initialCapacity
- The initial capacity of theWeakValueHashMap
- Throws:
IllegalArgumentException
- If the initial capacity is less than zero
-
WeakValueHashMap
public WeakValueHashMap()
Constructs a new, emptyWeakValueHashMap
with the default initial capacity and the default load factor, which is0.75
.
-
WeakValueHashMap
public WeakValueHashMap(Map<K,V> t)
Constructs a newWeakValueHashMap
with the same mappings as the specified Map. TheWeakValueHashMap
is created with an initial capacity of twice the number of mappings in the specified map or 11 (whichever is greater), and a default load factor, which is 0.75.- Parameters:
t
- the map whose mappings are to be placed in this map.- Since:
- 1.3
-
-
Method Detail
-
createMap
protected Map<K,WeakValueHashMap.ValueRef<K,V>> createMap()
Create map.- Returns:
- new map instance
-
size
public int size()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
- Overrides:
containsKey
in classAbstractMap<K,V>
-
clear
public void clear()
-
toString
public String toString()
- Overrides:
toString
in classAbstractMap<K,V>
-
-