Package com.pnfsoftware.jeb.util.collect
Class WeakValueMap<K,V>
java.lang.Object
com.pnfsoftware.jeb.util.collect.WeakValueMap<K,V>
- Type Parameters:
K- key typeV- value type
A pseudo-map whose values do not prevent garbage collection of entries. (The "opposite" of
WeakHashMap.) Key-value pairs with a null value should not be inserted to this map; no
guarantee on retrieval and persistence is provided for null values. The null key is allowed.
This map object supports serializability, on the condition that its key and value types are also serializable.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a weak-value map.WeakValueMap(int initialCapacity) Create a weak-value map.WeakValueMap(int initialCapacity, float loadFactor) Create a weak-value map.WeakValueMap(Map<K, V> t) Create a weak-value map initialized from another map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove all mappings.booleancontainsKey(Object key) booleancontainsValue(Object value) booleanRetrieve a value.inthashCode()booleanisEmpty()keySet()Add or replace a mapping.voidAdd all mappings from a map.Remove a mapping.intsize()toString()
-
Constructor Details
-
WeakValueMap
public WeakValueMap(int initialCapacity, float loadFactor) Create a weak-value map.- Parameters:
initialCapacity- initial capacityloadFactor- load factor
-
WeakValueMap
public WeakValueMap(int initialCapacity) Create a weak-value map.- Parameters:
initialCapacity- initial capacity
-
WeakValueMap
public WeakValueMap()Create a weak-value map. -
WeakValueMap
Create a weak-value map initialized from another map.- Parameters:
t- source map
-
-
Method Details
-
clear
public void clear()Remove all mappings. -
containsKey
- Parameters:
key- key- Returns:
- true if the key is present
-
containsValue
- Parameters:
value- value- Returns:
- true if a live value is equal to the provided value
-
get
Retrieve a value.- Parameters:
key- key- Returns:
- live value, or null
-
isEmpty
public boolean isEmpty()- Returns:
- true if no mapping exists
-
keySet
- Returns:
- key set view
-
put
Add or replace a mapping.- Parameters:
key- keyvalue- value to weakly reference- Returns:
- previous live value, or null
-
putAll
Add all mappings from a map.- Parameters:
m- source map
-
remove
Remove a mapping.- Parameters:
key- key- Returns:
- removed live value, or null
-
size
public int size()- Returns:
- number of mappings
-
hashCode
public int hashCode() -
equals
-
toString
-