public class SoftValueHashMap
extends java.util.AbstractMap
implements java.util.Map
| Modifier and Type | Class and Description |
|---|---|
private static class |
SoftValueHashMap.SoftValueRef |
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map |
hash |
private java.lang.ref.ReferenceQueue |
queue |
| Constructor and Description |
|---|
SoftValueHashMap()
Constructs a new, empty
WeakHashMap with the default
initial capacity and the default load factor, which is 0.75. |
SoftValueHashMap(int initialCapacity)
Constructs a new, empty
WeakHashMap with the given initial
capacity and the default load factor, which is 0.75. |
SoftValueHashMap(int initialCapacity,
float loadFactor)
Constructs a new, empty
WeakHashMap with the given initial
capacity and the given load factor. |
SoftValueHashMap(java.util.Map t)
Constructs a new
WeakHashMap with the same mappings as the
specified Map. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all mappings from this map.
|
boolean |
containsKey(java.lang.Object key)
Returns
true if this map contains a mapping for the
specified key. |
java.util.Set |
entrySet()
Returns a set of the mappings contained in this hash table.
|
java.lang.Object |
get(java.lang.Object key)
Returns the value to which this map maps the specified
key. |
boolean |
isEmpty()
Returns
true if this map contains no key-value mappings. |
private void |
processQueue() |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Updates this map so that the given
key maps to the given
value. |
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for the given
key from this map, if
present. |
int |
size()
Returns the number of key-value mappings in this map.
|
clone, containsValue, equals, hashCode, keySet, putAll, toString, valuespublic SoftValueHashMap(int initialCapacity,
float loadFactor)
WeakHashMap with the given initial
capacity and the given load factor.initialCapacity - The initial capacity of the WeakHashMaploadFactor - The load factor of the WeakHashMapjava.lang.IllegalArgumentException - If the initial capacity is less than zero, or if the load
factor is nonpositivepublic SoftValueHashMap(int initialCapacity)
WeakHashMap with the given initial
capacity and the default load factor, which is 0.75.initialCapacity - The initial capacity of the WeakHashMapjava.lang.IllegalArgumentException - If the initial capacity is less than zeropublic SoftValueHashMap()
WeakHashMap with the default
initial capacity and the default load factor, which is 0.75.public SoftValueHashMap(java.util.Map t)
WeakHashMap with the same mappings as the
specified Map. The WeakHashMap 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.public java.util.Set entrySet()
entrySet in interface java.util.MapentrySet in class java.util.AbstractMapprivate void processQueue()
public int size()
Map interface, the time required by this operation is
linear in the size of the map.size in interface java.util.Mapsize in class java.util.AbstractMappublic boolean isEmpty()
true if this map contains no key-value mappings.isEmpty in interface java.util.MapisEmpty in class java.util.AbstractMappublic boolean containsKey(java.lang.Object key)
true if this map contains a mapping for the
specified key.containsKey in interface java.util.MapcontainsKey in class java.util.AbstractMapkey - The key whose presence in this map is to be tested.public java.lang.Object get(java.lang.Object key)
key.
If this map does not contain a value for this key, then return
null.get in interface java.util.Mapget in class java.util.AbstractMapkey - The key whose associated value, if any, is to be returned.public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
key maps to the given
value. If the map previously contained a mapping for
key then that mapping is replaced and the previous value
is returned.put in interface java.util.Mapput in class java.util.AbstractMapkey - The key that is to be mapped to the given valuevalue - The value to which the given key is to be
mappednull if if there was no mapping for the keypublic java.lang.Object remove(java.lang.Object key)
key from this map, if
present.remove in interface java.util.Mapremove in class java.util.AbstractMapkey - The key whose mapping is to be removed.null if
there was no mapping for the key.public void clear()
clear in interface java.util.Mapclear in class java.util.AbstractMap