org.apache.openjpa.lib.util.concurrent
Class SizedConcurrentHashMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.concurrent.ConcurrentHashMap
org.apache.openjpa.lib.util.concurrent.NullSafeConcurrentHashMap
org.apache.openjpa.lib.util.concurrent.SizedConcurrentHashMap
- All Implemented Interfaces:
- java.io.Serializable, java.util.concurrent.ConcurrentMap, java.util.Map, SizedMap
public class SizedConcurrentHashMap
- extends NullSafeConcurrentHashMap
- implements SizedMap, ConcurrentMap, java.io.Serializable
An implementation of SizedMap that uses JDK1.5 concurrency primitives
- Since:
- 1.1.0
- See Also:
- Serialized Form
| Nested classes/interfaces inherited from interface java.util.Map |
java.util.Map.Entry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
java.util.Map.Entry<K,V> |
|
Method Summary |
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. |
| Methods inherited from class org.apache.openjpa.lib.util.concurrent.NullSafeConcurrentHashMap |
contains, containsKey, containsValue, elements, entrySet, get, keys, keySet, randomEntryIterator, remove, remove, removeRandom, replace, replace, values |
| Methods inherited from class java.util.concurrent.ConcurrentHashMap |
clear, isEmpty, putAll, size |
| Methods inherited from class java.util.AbstractMap |
clone, equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values |
| Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values |
SizedConcurrentHashMap
public SizedConcurrentHashMap(int size,
float load,
int concurrencyLevel)
- Parameters:
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 map- See Also:
ConcurrentHashMap
putIfAbsent
public java.lang.Object putIfAbsent(java.lang.Object key,
java.lang.Object value)
- Specified by:
putIfAbsent in interface java.util.concurrent.ConcurrentMap- Overrides:
putIfAbsent in class NullSafeConcurrentHashMap
put
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
- Specified by:
put in interface java.util.Map- Overrides:
put in class NullSafeConcurrentHashMap
getMaxSize
public int getMaxSize()
- Description copied from interface:
SizedMap
- The maximum number of entries, or Integer.MAX_VALUE for no limit.
- Specified by:
getMaxSize in interface SizedMap
setMaxSize
public void setMaxSize(int max)
- Description copied from interface:
SizedMap
- The maximum number of entries, or Integer.MAX_VALUE for no limit.
- Specified by:
setMaxSize in interface SizedMap
removeOverflow
protected void removeOverflow()
- Equivalent to
removeOverflow(false).
removeOverflow
protected void removeOverflow(boolean forPut)
- Removes overflow. If
forPut is true, then
this uses size() + 1 when computing size.
isFull
public boolean isFull()
- Description copied from interface:
SizedMap
- Whether the map is full.
- Specified by:
isFull in interface SizedMap
overflowRemoved
public void overflowRemoved(java.lang.Object key,
java.lang.Object value)
- This implementation does nothing.
- Specified by:
overflowRemoved in interface SizedMap
Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.