public class SoftMap<K,V>
extends java.util.AbstractMap<K,V>
implements java.util.Map<K,V>
When the object has been finalized it will no longer be available in this map and the soft reference pointing to the object will be removed. But until the object is finalized it is possible to get a strong reference to it.
Use this class to minimize the use of memory when caching object instances since it is specified that all soft references are cleared and finalized before the JVM raises an java.lang.OutOfMemoryError.
Constructor and Description |
---|
SoftMap()
No argument constructor.
|
SoftMap(int i)
Constructs a soft cache map with the specified initial capacity.
|
SoftMap(int i,
float f)
Constructs a soft cache map with the specified initial capacity and load
factor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the map.
|
boolean |
containsKey(java.lang.Object obj)
Returns true if the map contains the specified key.
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
Returns the entry set.
|
protected V |
fill(java.lang.Object obj)
Does nothing.
|
V |
get(java.lang.Object obj)
Returns the object bound to the specified key.
|
boolean |
isEmpty()
Returns true if the map is empty.
|
V |
put(K key,
V value)
Puts the specified value in the map bound to the specified key.
|
V |
remove(java.lang.Object obj)
Removes the object bound to the specified key.
|
int |
size()
Returns the size of the map.
|
clone, containsValue, equals, hashCode, keySet, putAll, toString, values
public SoftMap(int i, float f)
public SoftMap(int i)
public SoftMap()
public int size()
public boolean isEmpty()
public boolean containsKey(java.lang.Object obj)
protected V fill(java.lang.Object obj)
public V get(java.lang.Object obj)
public V remove(java.lang.Object obj)
public void clear()
Copyright © Technia AB. All Rights Reserved.