org.apache.openjpa.lib.util.concurrent
Class SizedConcurrentHashMap

java.lang.Object
  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

Since:
1.1.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.openjpa.lib.util.concurrent.NullSafeConcurrentHashMap
NullSafeConcurrentHashMap.KeyFilter
 
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
Map.Entry<K,V>
 
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

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

putIfAbsent

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

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface 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(Object key,
                            Object value)
This implementation does nothing.

Specified by:
overflowRemoved in interface SizedMap


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