Package org.intermine.util
Class WeakReferenceHashMap<K,V>
- java.lang.Object
-
- org.intermine.util.ReferenceMap<K,V>
-
- org.intermine.util.WeakReferenceMap<K,V>
-
- org.intermine.util.WeakReferenceHashMap<K,V>
-
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values
- All Implemented Interfaces:
java.util.Map<K,V>
public class WeakReferenceHashMap<K,V> extends WeakReferenceMap<K,V>
This is a Map implementation designed specifically for people intending to create a cache. The keys are held strongly, but the values are held weakly, so the values can be garbage-collected. When an entry is garbage-collected, its key is removed from the Map on the next Map activity.The entrySet() and values() methods of this class do not work.
- Author:
- Matthew Wakeling
- See Also:
WeakReference
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.intermine.util.ReferenceMap
ReferenceMap.ReferenceWithKey<K>
-
-
Field Summary
-
Fields inherited from class org.intermine.util.ReferenceMap
name, NULL_VALUE, queue, subMap
-
-
Constructor Summary
Constructors Constructor Description WeakReferenceHashMap()
Constructs a new, empty WeakReferenceHashMap with the default initial capacity (16) and the default load factor (0.75).WeakReferenceHashMap(int initialCapacity)
Constructs a new, empty WeakReferenceHashMap with the given initial capacity and the default load factor, which is 0.75.WeakReferenceHashMap(int initialCapacity, float loadFactor)
Constructs a new, empty WeakReferenceHashMap with the given initial capacity and the given load factor.WeakReferenceHashMap(java.lang.String name)
Constructs a new, empty WeakReferenceHashMap with the default initial capacity (16) and the default load factor (0.75), and a name.WeakReferenceHashMap(java.util.Map<K,V> t)
Constructs a new WeakReferenceHashMap with the same mappings as the specified Map.
-
Method Summary
-
Methods inherited from class org.intermine.util.WeakReferenceMap
newRef
-
Methods inherited from class org.intermine.util.ReferenceMap
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
-
-
-
-
Constructor Detail
-
WeakReferenceHashMap
public WeakReferenceHashMap(int initialCapacity, float loadFactor)
Constructs a new, empty WeakReferenceHashMap with the given initial capacity and the given load factor.- Parameters:
initialCapacity
- The initial capacity of the WeakReferenceHashMaploadFactor
- The load factor of the WeakReferenceHashMap- Throws:
java.lang.IllegalArgumentException
- If the initial capacity is negative, or if the load factor is nonpositive.
-
WeakReferenceHashMap
public WeakReferenceHashMap(int initialCapacity)
Constructs a new, empty WeakReferenceHashMap with the given initial capacity and the default load factor, which is 0.75.- Parameters:
initialCapacity
- The initial capacity of the WeakReferenceHashMap- Throws:
java.lang.IllegalArgumentException
- If the initial capacity is negative.
-
WeakReferenceHashMap
public WeakReferenceHashMap()
Constructs a new, empty WeakReferenceHashMap with the default initial capacity (16) and the default load factor (0.75).
-
WeakReferenceHashMap
public WeakReferenceHashMap(java.lang.String name)
Constructs a new, empty WeakReferenceHashMap with the default initial capacity (16) and the default load factor (0.75), and a name.- Parameters:
name
- the name of the WeakReferenceHashMap - printed out in log messages
-
WeakReferenceHashMap
public WeakReferenceHashMap(java.util.Map<K,V> t)
Constructs a new WeakReferenceHashMap with the same mappings as the specified Map. The WeakReferenceHashMap is created with default load factor, which is 0.75 and an initial capacity sufficient to hold the mappings in the specified Map.- Parameters:
t
- the map whose mappings are to be placed in this map.- Throws:
java.lang.NullPointerException
- if the specified map is null.
-
-