Class SizedConcurrentHashMap

  extended by java.util.AbstractMap<K,V>
      extended by java.util.concurrent.ConcurrentHashMap
          extended by org.apache.openjpa.lib.util.concurrent.NullSafeConcurrentHashMap
              extended by org.apache.openjpa.lib.util.concurrent.SizedConcurrentHashMap
All Implemented Interfaces:
Serializable, ConcurrentMap, Map, SizedMap

public class SizedConcurrentHashMap
extends NullSafeConcurrentHashMap
implements SizedMap, ConcurrentMap, Serializable

An implementation of SizedMap that uses JDK1.5 concurrency primitives

See Also:
Serialized Form

Nested Class Summary
Nested classes/interfaces inherited from class org.apache.openjpa.lib.util.concurrent.NullSafeConcurrentHashMap
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Nested classes/interfaces inherited from interface java.util.Map
Constructor Summary
SizedConcurrentHashMap(int size, float load, int concurrencyLevel)
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(Object key, Object value)
          This implementation does nothing.
 Object put(Object key, Object value)
 Object putIfAbsent(Object key, 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 org.apache.openjpa.lib.util.concurrent.ConcurrentMap
randomEntryIterator, removeRandom
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values

Constructor Detail


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 map
concurrencyLevel - the concurrency level for the underlying map
See Also:
Method Detail


public Object putIfAbsent(Object key,
                          Object value)
Specified by:
putIfAbsent in interface ConcurrentMap
putIfAbsent in class NullSafeConcurrentHashMap


public Object put(Object key,
                  Object value)
Specified by:
put in interface Map
put in class NullSafeConcurrentHashMap


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


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


protected void removeOverflow()
Equivalent to removeOverflow(false).


protected void removeOverflow(boolean forPut)
Removes overflow. If forPut is true, then this uses size() + 1 when computing size.


public boolean isFull()
Description copied from interface: SizedMap
Whether the map is full.

Specified by:
isFull in interface SizedMap


public void overflowRemoved(Object key,
                            Object value)
This implementation does nothing.

Specified by:
overflowRemoved in interface SizedMap

Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.