public abstract class ReferenceValueMap extends Object implements Map, Cloneable
java.util.Map
implementation using reference values.
The values are stored in the map as references. If the garbage collector clears the reference, the corresponding key is automatically removed from the map.
Reference
Modifier and Type | Class and Description |
---|---|
static interface |
ReferenceValueMap.ValueReference
References returned by
newValueReference must implement
this interface to provide the corresponding map key for the value. |
Constructor and Description |
---|
ReferenceValueMap()
Default Constructor.
|
ReferenceValueMap(int initial_capacity)
Constructor taking initial capacity.
|
ReferenceValueMap(int initial_capacity,
float load_factor)
Constructor taking initial capacity and load factor.
|
ReferenceValueMap(Map m)
Constructor taking initial Map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Method to empty the HashMap.
|
Object |
clone()
Clone method.
|
boolean |
containsKey(Object obj)
Accessor for whether the Map contains the specified Key
|
boolean |
containsValue(Object obj)
Accessor for whether the Map contains the specified value.
|
Set |
entrySet()
Accessor for the entry set.
|
boolean |
equals(Object o)
Equality operator.
|
Object |
get(Object key)
Method to get a value for a key.
|
int |
hashCode()
Hashcode generator for this object.
|
boolean |
isEmpty()
Accessor for whether the Map is empty.
|
Set |
keySet()
Accessor for the Set of keys in the Map.
|
protected abstract ReferenceValueMap.ValueReference |
newValueReference(Object key,
Object value,
ReferenceQueue queue)
Returns a new
Reference object to be inserted into the map. |
Object |
put(Object key,
Object value)
Method to add an object to the Map.
|
void |
putAll(Map m)
Method to add the contents of a Map.
|
void |
reap()
Utility method to reap objects.
|
Object |
remove(Object key)
Method to remove an object for the specified key.
|
int |
size()
Accessor for the size of the HashMap.
|
Collection |
values()
Accessor for the values from the Map.
|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public ReferenceValueMap()
public ReferenceValueMap(int initial_capacity)
initial_capacity
- Initial Capacity of HashMappublic ReferenceValueMap(int initial_capacity, float load_factor)
initial_capacity
- Initial Capacity of HashMapload_factor
- Load Factor of HashMappublic ReferenceValueMap(Map m)
m
- Map to initial with.public Object clone()
protected abstract ReferenceValueMap.ValueReference newValueReference(Object key, Object value, ReferenceQueue queue)
Reference
object to be inserted into the map.
Subclasses must implement this method to construct Reference
objects of the desired type (e.g. SoftReference
, etc.).key
- The key that will be inserted.value
- The associated value to be referenced.queue
- The ReferenceQueue
with which to register the
new Reference
object.public void putAll(Map m)
public int size()
public boolean containsKey(Object obj)
containsKey
in interface Map
obj
- The keypublic boolean containsValue(Object obj)
containsValue
in interface Map
obj
- The valuepublic boolean isEmpty()
public Set keySet()
public Collection values()
public Set entrySet()
public int hashCode()
public boolean equals(Object o)
public void reap()
Copyright © 2017. All rights reserved.