public class ConcurrentReferenceHashMap extends java.util.AbstractMap implements ConcurrentMap, ReferenceMap, SizedMap, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
(package private) static double[] |
RANDOMS
Cache of random numbers used in "random" methods, since generating them
is expensive.
|
HARD, SOFT, WEAK
Constructor and Description |
---|
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,
java.util.Map t)
Constructs a new HashMap with the same mappings as the given
Map.
|
Modifier and Type | Method and Description |
---|---|
(package private) int |
capacity() |
void |
clear()
Removes all mappings from this HashMap.
|
java.lang.Object |
clone()
Returns a shallow copy of this HashMap.
|
boolean |
containsKey(java.lang.Object key)
Returns true if this HashMap contains a mapping for the specified key.
|
boolean |
containsValue(java.lang.Object value)
Returns true if this HashMap maps one or more keys to the specified
value.
|
java.util.Set |
entrySet()
Returns a Collection view of the mappings contained in this HashMap.
|
protected boolean |
eq(java.lang.Object x,
java.lang.Object y)
Compare two objects.
|
java.lang.Object |
get(java.lang.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(java.lang.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(java.lang.Object value)
Overridable callback for when a key reference expires.
|
java.util.Set |
keySet()
Returns a Set view of the keys contained in this HashMap.
|
(package private) float |
loadFactor() |
void |
overflowRemoved(java.lang.Object key,
java.lang.Object value)
Overridable callback for when an overflow entry is automatically removed.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in this HashMap.
|
void |
putAll(java.util.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.
|
java.util.Iterator |
randomEntryIterator()
Iterate over map entries, beginning at an arbitrary
(not strictly random) entry.
|
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key from this HashMap if present.
|
void |
removeExpired()
Purge stale entries.
|
java.util.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(java.lang.Object key)
Overridable callback for when a value reference expires.
|
java.util.Collection |
values()
Returns a Collection view of the values contained in this HashMap.
|
static final double[] RANDOMS
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.java.lang.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 zeropublic 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 valuespublic ConcurrentReferenceHashMap(int keyType, int valueType, java.util.Map t)
keyType
- the reference type of map keysvalueType
- the reference type of map valuesprotected boolean eq(java.lang.Object x, java.lang.Object y)
protected int hc(java.lang.Object o)
Object.hashCode()
public int getMaxSize()
SizedMap
getMaxSize
in interface SizedMap
public void setMaxSize(int maxSize)
SizedMap
setMaxSize
in interface SizedMap
public boolean isFull()
SizedMap
public void overflowRemoved(java.lang.Object key, java.lang.Object value)
SizedMap
overflowRemoved
in interface SizedMap
public int size()
size
in interface java.util.Map
size
in class java.util.AbstractMap
public boolean isEmpty()
isEmpty
in interface java.util.Map
isEmpty
in class java.util.AbstractMap
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
containsValue
in class java.util.AbstractMap
value
- value whose presence in this Map is to be tested.public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
containsKey
in class java.util.AbstractMap
key
- key whose presence in this Map is to be tested.public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
get
in class java.util.AbstractMap
key
- key whose associated value is to be returned.public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
put
in class java.util.AbstractMap
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
remove
in class java.util.AbstractMap
key
- key whose mapping is to be removed from the Map.public void removeExpired()
ReferenceMap
removeExpired
in interface ReferenceMap
public void keyExpired(java.lang.Object value)
ReferenceMap
keyExpired
in interface ReferenceMap
value
- the value for the expired keypublic void valueExpired(java.lang.Object key)
ReferenceMap
valueExpired
in interface ReferenceMap
key
- the key for the expired valuepublic java.util.Map.Entry removeRandom()
ConcurrentMap
removeRandom
in interface ConcurrentMap
public java.util.Iterator randomEntryIterator()
ConcurrentMap
randomEntryIterator
in interface ConcurrentMap
public void putAll(java.util.Map t)
putAll
in interface java.util.Map
putAll
in class java.util.AbstractMap
t
- Mappings to be stored in this Map.public void clear()
clear
in interface java.util.Map
clear
in class java.util.AbstractMap
public java.lang.Object clone()
clone
in class java.util.AbstractMap
public java.util.Set keySet()
keySet
in interface java.util.Map
keySet
in class java.util.AbstractMap
public java.util.Collection values()
values
in interface java.util.Map
values
in class java.util.AbstractMap
public java.util.Set entrySet()
entrySet
in interface java.util.Map
entrySet
in class java.util.AbstractMap
Map.Entry
int capacity()
float loadFactor()
Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.