public class SoftCache
extends java.util.AbstractMap
The SoftCache does not maintain any strong/hard references to any of its entry values. To prevent an entry in the SoftCache from being reclaimed by garbage-collection, external code must maintain a hard reference to the values object in question.
| Constructor and Description |
|---|
SoftCache()
Constructs an empty SoftCache with the default initial capacity
(16) and the default load factor (0.75).
|
SoftCache(int initialCapacity)
Constructs an empty SoftCache with the specified initial
capacity and the default load factor (0.75).
|
SoftCache(int initialCapacity,
float loadFactor)
Constructs an empty SoftCache with the specified initial
capacity and load factor.
|
SoftCache(java.util.Map m)
Constructs a new SoftCache with the same mappings as the
specified Map.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all mappings from this map (optional operation).
|
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 view of the mappings contained in this map.
|
java.lang.Object |
get(java.lang.Object key)
Returns the value to which this map maps the specified key.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in this map
(optional operation).
|
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key from this map if present.
|
int |
size()
Returns the number of key-value mappings in this map.
|
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, valuespublic SoftCache(int initialCapacity,
float loadFactor)
initialCapacity - The initial capacity.loadFactor - The load factor.java.lang.IllegalArgumentException - if the initial capacity is negative
or the load factor is nonpositive.public SoftCache(int initialCapacity)
initialCapacity - the initial capacity.java.lang.IllegalArgumentException - if the initial capacity is negative.public SoftCache()
public SoftCache(java.util.Map m)
m - the map whose mappings are to be placed in this map.java.lang.NullPointerException - if the specified map is null.public java.util.Set entrySet()
entrySet in interface java.util.MapentrySet in class java.util.AbstractMappublic int size()
This implementation returns entrySet().size().
size in interface java.util.Mapsize in class java.util.AbstractMappublic void clear()
clear in interface java.util.Mapclear in class java.util.AbstractMappublic boolean containsKey(java.lang.Object key)
This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, true is returned. If the iteration terminates without finding such an entry, false is returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.
containsKey in interface java.util.MapcontainsKey in class java.util.AbstractMapkey - key whose presence in this map is to be tested.java.lang.NullPointerException - key is null and this map does not
not permit null keys.public java.lang.Object get(java.lang.Object key)
get in interface java.util.Mapget in class java.util.AbstractMapkey - key whose associated value is to be returned.java.lang.NullPointerException - if the key is null and this map
does not not permit null keys.containsKey(Object)public java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mapremove in class java.util.AbstractMapkey - key whose mapping is to be removed from the map.public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
put in interface java.util.Mapput in class java.util.AbstractMapkey - key with which the specified value is to be associated.value - value to be associated with the specified key.java.lang.NullPointerException - this map does not permit null
keys or values, and the specified key or value is
null.