K
- the key typeV
- the value typepublic final class WeakValueHashMap<K,V>
extends java.util.AbstractMap<K,V>
Modifier and Type | Class and Description |
---|---|
private class |
WeakValueHashMap.EntrySet
EntrySet.
|
private class |
WeakValueHashMap.EntrySetIterator
EntrySet iterator
|
static interface |
WeakValueHashMap.ValueRef<K,V> |
private static class |
WeakValueHashMap.WeakValueRef<K,V>
Weak value ref.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<K,WeakValueHashMap.ValueRef<K,V>> |
map
Hash table mapping keys to ref values
|
private java.lang.ref.ReferenceQueue<V> |
queue
Reference queue for cleared RefKeys
|
Constructor and Description |
---|
WeakValueHashMap()
Constructs a new, empty
WeakValueHashMap with the default
initial capacity and the default load factor, which is
0.75 . |
WeakValueHashMap(int initialCapacity)
Constructs a new, empty
WeakValueHashMap with the given
initial capacity and the default load factor, which is
0.75 . |
WeakValueHashMap(int initialCapacity,
float loadFactor)
Constructs a new, empty
WeakValueHashMap with the given
initial capacity and the given load factor. |
WeakValueHashMap(java.util.Map<K,V> t)
Constructs a new
WeakValueHashMap with the same mappings as
the specified Map. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
private WeakValueHashMap.ValueRef<K,V> |
create(K key,
V value,
java.lang.ref.ReferenceQueue<V> q)
Create new value ref instance.
|
protected java.util.Map<K,WeakValueHashMap.ValueRef<K,V>> |
createMap()
Create map.
|
private java.util.Map<K,WeakValueHashMap.ValueRef<K,V>> |
createMap(int initialCapacity)
Create map.
|
private java.util.Map<K,WeakValueHashMap.ValueRef<K,V>> |
createMap(int initialCapacity,
float loadFactor)
Create map.
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key) |
private void |
processQueue()
Remove all entries whose values have been discarded.
|
V |
put(K key,
V value) |
V |
remove(java.lang.Object key) |
int |
size() |
java.lang.String |
toString() |
private java.util.Map<K,WeakValueHashMap.ValueRef<K,V>> map
private java.lang.ref.ReferenceQueue<V> queue
public WeakValueHashMap(int initialCapacity, float loadFactor)
WeakValueHashMap
with the given
initial capacity and the given load factor.initialCapacity
- The initial capacity of the WeakValueHashMap
loadFactor
- The load factor of the WeakValueHashMap
java.lang.IllegalArgumentException
- If the initial capacity is less than
zero, or if the load factor is
nonpositivepublic WeakValueHashMap(int initialCapacity)
WeakValueHashMap
with the given
initial capacity and the default load factor, which is
0.75
.initialCapacity
- The initial capacity of the WeakValueHashMap
java.lang.IllegalArgumentException
- If the initial capacity is less than
zeropublic WeakValueHashMap()
WeakValueHashMap
with the default
initial capacity and the default load factor, which is
0.75
.public WeakValueHashMap(java.util.Map<K,V> t)
WeakValueHashMap
with the same mappings as
the specified Map. The WeakValueHashMap
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.t
- the map whose mappings are to be placed in this map.private WeakValueHashMap.ValueRef<K,V> create(K key, V value, java.lang.ref.ReferenceQueue<V> q)
key
- the keyvalue
- the valueq
- the ref queueprivate java.util.Map<K,WeakValueHashMap.ValueRef<K,V>> createMap(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacityloadFactor
- the load factorprivate java.util.Map<K,WeakValueHashMap.ValueRef<K,V>> createMap(int initialCapacity)
initialCapacity
- the initial capacityprotected java.util.Map<K,WeakValueHashMap.ValueRef<K,V>> createMap()
public int size()
public boolean containsKey(java.lang.Object key)
public V get(java.lang.Object key)
public V remove(java.lang.Object key)
public void clear()
private void processQueue()