|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap
org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashMap
public class ConcurrentReferenceHashMap
This class implements a HashMap which has limited synchronization and reference keys or values(but not both). In particular mutators are generally synchronized while accessors are generally not. Additionally the Iterators returned by this class are not "fail-fast", but instead try to continue to iterate over the data structure after changes have been made. Finally purging of the reference queue is only done inside mutators. Null keys are not supported if keys use references. Null values are not supported if values use references. This class is based heavily on the WeakHashMap class in the Java collections package.
| Field Summary |
|---|
| Fields inherited from interface org.apache.openjpa.lib.util.ReferenceMap |
|---|
HARD, SOFT, WEAK |
| Constructor Summary | |
|---|---|
ConcurrentReferenceHashMap(int keyType,
int valueType)
Constructs a new, empty HashMap with a default capacity and load factor. |
|
ConcurrentReferenceHashMap(int keyType,
int valueType,
int initialCapacity)
Constructs a new, empty HashMap with the specified initial capacity and default load factor. |
|
ConcurrentReferenceHashMap(int keyType,
int valueType,
int initialCapacity,
float loadFactor)
Constructs a new, empty HashMap with the specified initial capacity and the specified load factor. |
|
ConcurrentReferenceHashMap(int keyType,
int valueType,
Map t)
Constructs a new HashMap with the same mappings as the given Map. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all mappings from this HashMap. |
Object |
clone()
Returns a shallow copy of this HashMap. |
boolean |
containsKey(Object key)
Returns true if this HashMap contains a mapping for the specified key. |
boolean |
containsValue(Object value)
Returns true if this HashMap maps one or more keys to the specified value. |
Set |
entrySet()
Returns a Collection view of the mappings contained in this HashMap. |
protected boolean |
eq(Object x,
Object y)
Compare two objects. |
Object |
get(Object key)
Returns the value to which this HashMap maps the specified key. |
int |
getMaxSize()
The maximum number of entries, or Integer.MAX_VALUE for no limit. |
protected int |
hc(Object o)
Obtain the hashcode of an object. |
boolean |
isEmpty()
Returns true if this Map contains no key-value mappings. |
boolean |
isFull()
Whether the map is full. |
void |
keyExpired(Object value)
Overridable callback for when a key reference expires. |
Set |
keySet()
Returns a Set view of the keys contained in this HashMap. |
void |
overflowRemoved(Object key,
Object value)
Overridable callback for when an overflow entry is automatically removed. |
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this HashMap. |
void |
putAll(Map t)
Copies all of the mappings from the specified Map to this HashMap These mappings will replace any mappings that this HashMap had for any of the keys currently in the specified Map. |
Iterator |
randomEntryIterator()
Iterate over map entries, beginning at an arbitrary (not strictly random) entry. |
Object |
remove(Object key)
Removes the mapping for this key from this HashMap if present. |
void |
removeExpired()
Purge stale entries. |
Map.Entry |
removeRandom()
Remove an arbitrary(not strictly random) entry from the map. |
void |
setMaxSize(int maxSize)
The maximum number of entries, or Integer.MAX_VALUE for no limit. |
int |
size()
Returns the number of key-value mappings in this Map. |
void |
valueExpired(Object key)
Overridable callback for when a value reference expires. |
Collection |
values()
Returns a Collection view of the values contained in this HashMap. |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public ConcurrentReferenceHashMap(int keyType,
int valueType,
int initialCapacity,
float loadFactor)
keyType - the reference type of map keysvalueType - the reference type of map valuesinitialCapacity - the initial capacity of the HashMap.loadFactor - a number between 0.0 and 1.0.
IllegalArgumentException - if neither keys nor values use hard
references, if the initial capacity is less than or equal to zero, or if
the load factor is less than or equal to zero
public ConcurrentReferenceHashMap(int keyType,
int valueType,
int initialCapacity)
keyType - the reference type of map keysvalueType - the reference type of map valuesinitialCapacity - the initial capacity of the HashMap.
public ConcurrentReferenceHashMap(int keyType,
int valueType)
keyType - the reference type of map keysvalueType - the reference type of map values
public ConcurrentReferenceHashMap(int keyType,
int valueType,
Map t)
keyType - the reference type of map keysvalueType - the reference type of map values| Method Detail |
|---|
protected boolean eq(Object x,
Object y)
protected int hc(Object o)
Object.hashCode()
public int getMaxSize()
SizedMap
getMaxSize in interface SizedMappublic void setMaxSize(int maxSize)
SizedMap
setMaxSize in interface SizedMappublic boolean isFull()
SizedMap
isFull in interface SizedMap
public void overflowRemoved(Object key,
Object value)
SizedMap
overflowRemoved in interface SizedMappublic int size()
size in interface Mapsize in class AbstractMappublic boolean isEmpty()
isEmpty in interface MapisEmpty in class AbstractMappublic boolean containsValue(Object value)
containsValue in interface MapcontainsValue in class AbstractMapvalue - value whose presence in this Map is to be tested.public boolean containsKey(Object key)
containsKey in interface MapcontainsKey in class AbstractMapkey - key whose presence in this Map is to be tested.public Object get(Object key)
get in interface Mapget in class AbstractMapkey - key whose associated value is to be returned.
public Object put(Object key,
Object value)
put in interface Mapput in class AbstractMapkey - key with which the specified value is to be associated.value - value to be associated with the specified key.
public Object remove(Object key)
remove in interface Mapremove in class AbstractMapkey - key whose mapping is to be removed from the Map.
public void removeExpired()
ReferenceMap
removeExpired in interface ReferenceMappublic void keyExpired(Object value)
ReferenceMap
keyExpired in interface ReferenceMapvalue - the value for the expired keypublic void valueExpired(Object key)
ReferenceMap
valueExpired in interface ReferenceMapkey - the key for the expired valuepublic Map.Entry removeRandom()
ConcurrentMap
removeRandom in interface ConcurrentMappublic Iterator randomEntryIterator()
ConcurrentMap
randomEntryIterator in interface ConcurrentMappublic void putAll(Map t)
putAll in interface MapputAll in class AbstractMapt - Mappings to be stored in this Map.public void clear()
clear in interface Mapclear in class AbstractMappublic Object clone()
clone in class AbstractMappublic Set keySet()
keySet in interface MapkeySet in class AbstractMappublic Collection values()
values in interface Mapvalues in class AbstractMappublic Set entrySet()
entrySet in interface MapentrySet in class AbstractMapMap.Entry
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||