Package org.jboss.util.collection
Class SoftValueHashMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.jboss.util.collection.ReferenceValueMap<K,V>
-
- org.jboss.util.collection.ReferenceValueHashMap<K,V>
-
- org.jboss.util.collection.SoftValueHashMap<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
public class SoftValueHashMap<K,V> extends ReferenceValueHashMap<K,V>
This Map will remove entries when the value in the map has been cleaned from garbage collection
-
-
Constructor Summary
Constructors Constructor Description SoftValueHashMap()
Constructs a new, emptySoftValueHashMap
with the default initial capacity and the default load factor, which is0.75
.SoftValueHashMap(int initialCapacity)
Constructs a new, emptySoftValueHashMap
with the given initial capacity and the default load factor, which is0.75
.SoftValueHashMap(int initialCapacity, float loadFactor)
Constructs a new, emptySoftValueHashMap
with the given initial capacity and the given load factor.SoftValueHashMap(java.util.Map<K,V> t)
Constructs a newSoftValueHashMap
with the same mappings as the specified Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ValueRef<K,V>
create(K key, V value, java.lang.ref.ReferenceQueue<V> q)
Create new value ref instance.-
Methods inherited from class org.jboss.util.collection.ReferenceValueHashMap
createMap, createMap, createMap, createMap, createMap
-
Methods inherited from class org.jboss.util.collection.ReferenceValueMap
clear, containsKey, entrySet, get, put, remove, size, toString
-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, values
-
-
-
-
Constructor Detail
-
SoftValueHashMap
public SoftValueHashMap(int initialCapacity, float loadFactor)
Constructs a new, emptySoftValueHashMap
with the given initial capacity and the given load factor.- Parameters:
initialCapacity
- The initial capacity of theSoftValueHashMap
loadFactor
- The load factor of theSoftValueHashMap
- Throws:
java.lang.IllegalArgumentException
- If the initial capacity is less than zero, or if the load factor is nonpositive
-
SoftValueHashMap
public SoftValueHashMap(int initialCapacity)
Constructs a new, emptySoftValueHashMap
with the given initial capacity and the default load factor, which is0.75
.- Parameters:
initialCapacity
- The initial capacity of theSoftValueHashMap
- Throws:
java.lang.IllegalArgumentException
- If the initial capacity is less than zero
-
SoftValueHashMap
public SoftValueHashMap()
Constructs a new, emptySoftValueHashMap
with the default initial capacity and the default load factor, which is0.75
.
-
SoftValueHashMap
public SoftValueHashMap(java.util.Map<K,V> t)
Constructs a newSoftValueHashMap
with the same mappings as the specified Map. TheSoftValueHashMap
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
-
create
protected ValueRef<K,V> create(K key, V value, java.lang.ref.ReferenceQueue<V> q)
Description copied from class:ReferenceValueMap
Create new value ref instance.- Specified by:
create
in classReferenceValueMap<K,V>
- Parameters:
key
- the keyvalue
- the valueq
- the ref queue- Returns:
- new value ref instance
-
-