public class ReferenceMap
extends java.lang.Object
When you construct a ReferenceMap, you can
specify what kind of references are used to store the
map's values. If non-hard references are
used, then the garbage collector can remove mappings
if a value becomes unreachable, or if the
JVM's memory is running low. For information on how
the different reference types behave, see
Reference.
The algorithms used are basically the same as those
in HashMap. In particular, you
can specify a load factor and capacity to suit your
needs.
This map does not allow null values. Attempting to add a null
value to the map will raise a NullPointerException.
This data structure is not synchronized.
Reference| Modifier and Type | Field and Description |
|---|---|
static int |
HARD
Constant indicating that hard references should be used.
|
static int |
SOFT
Constant indiciating that soft references should be used.
|
| Constructor and Description |
|---|
ReferenceMap(int referenceType,
int capacity,
float loadFactor)
Constructs a new
ReferenceMap with the
specified reference type, load factor and initial
capacity. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
get(int key)
Returns the value associated with the given key, if any.
|
void |
put(int key,
java.lang.Object value)
Associates the given key with the given value.
|
java.lang.Object |
remove(int key)
Removes the key and its associated value from this map.
|
public static final int HARD
public static final int SOFT
public ReferenceMap(int referenceType,
int capacity,
float loadFactor)
ReferenceMap with the
specified reference type, load factor and initial
capacity.public java.lang.Object get(int key)
null
if the key maps to no valuepublic void put(int key,
java.lang.Object value)
Neither the key nor the value may be null.
key - the key of the mappingvalue - the value of the mappingjava.lang.NullPointerException - if either the key or value
is nullpublic java.lang.Object remove(int key)
key - the key to remove