org.apache.openjpa.lib.util.concurrent
public class SizedConcurrentHashMap extends NullSafeConcurrentHashMap implements SizedMap, ConcurrentMap, java.io.Serializable
SizedMap
that uses JDK1.5 concurrency primitivesNullSafeConcurrentHashMap.KeyFilter
Constructor and Description |
---|
SizedConcurrentHashMap(int size,
float load,
int concurrencyLevel) |
Modifier and Type | Method and Description |
---|---|
int |
getMaxSize()
The maximum number of entries, or Integer.MAX_VALUE for no limit.
|
boolean |
isFull()
Whether the map is full.
|
void |
overflowRemoved(java.lang.Object key,
java.lang.Object value)
This implementation does nothing.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value) |
java.lang.Object |
putIfAbsent(java.lang.Object key,
java.lang.Object value) |
protected void |
removeOverflow()
Equivalent to
removeOverflow(false) . |
protected void |
removeOverflow(boolean forPut)
Removes overflow.
|
void |
setMaxSize(int max)
The maximum number of entries, or Integer.MAX_VALUE for no limit.
|
contains, containsKey, containsValue, elements, entrySet, get, keys, keySet, randomEntryIterator, remove, remove, removeRandom, replace, replace, values
finalize, getClass, notify, notifyAll, wait, wait, wait
randomEntryIterator, removeRandom
public SizedConcurrentHashMap(int size, float load, int concurrencyLevel)
size
- the maximum size of this map. If additional elements are
put into the map, overflow will be removed via calls to
overflowRemoved(java.lang.Object, java.lang.Object)
.load
- the load factor for the underlying mapconcurrencyLevel
- the concurrency level for the underlying mapConcurrentHashMap
public java.lang.Object putIfAbsent(java.lang.Object key, java.lang.Object value)
putIfAbsent
in interface java.util.concurrent.ConcurrentMap
putIfAbsent
in class NullSafeConcurrentHashMap
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
put
in class NullSafeConcurrentHashMap
public int getMaxSize()
SizedMap
getMaxSize
in interface SizedMap
public void setMaxSize(int max)
SizedMap
setMaxSize
in interface SizedMap
protected void removeOverflow()
removeOverflow(false)
.protected void removeOverflow(boolean forPut)
forPut
is true
, then
this uses size() + 1
when computing size.public boolean isFull()
SizedMap
public void overflowRemoved(java.lang.Object key, java.lang.Object value)
overflowRemoved
in interface SizedMap