|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap
org.apache.openjpa.lib.util.concurrent.ConcurrentHashMap
public class ConcurrentHashMap
This class implements a HashMap which has limited synchronization. In particular mutators are generally synchronized while accessors are generally not. Additionally the Iterators returned by this class are not "fail-fast", but instead try to continue to iterate over the data structure after changes have been made. The synchronization semantics are built right in to the implementation rather than using a delegating wrapper like the other collection classes do because it wasn't clear to me that the how the two should be seperated or that it would be useful to do so. This can probably be a topic for further debate in the future. This class is based heavily on the HashMap class in the Java collections package.
| Nested Class Summary | |
|---|---|
protected static class |
ConcurrentHashMap.Entry
|
| Constructor Summary | |
|---|---|
ConcurrentHashMap()
Constructs an empty ConcurrentHashMap with the default initial capacity(16) and the default load factor(0.75). |
|
ConcurrentHashMap(int initialCapacity)
Constructs an empty ConcurrentHashMap with the specified initial capacity and the default load factor(0.75). |
|
ConcurrentHashMap(int initialCapacity,
float loadFactor)
Constructs an empty ConcurrentHashMap with the specified initial capacity and load factor. |
|
ConcurrentHashMap(java.util.Map m)
Constructs a new ConcurrentHashMap with the same mappings as the specified Map. |
|
| Method Summary | |
|---|---|
int |
capacity()
Returns the current capacity of backing table in this map. |
void |
clear()
Removes all mappings from this map. |
java.lang.Object |
clone()
Returns a shallow copy of this ConcurrentHashMap instance: the keys and values themselves are not cloned. |
boolean |
containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more keys to the specified value. |
protected ConcurrentHashMap.Entry |
createEntry(int h,
java.lang.Object k,
java.lang.Object v,
ConcurrentHashMap.Entry n)
|
java.util.Set |
entrySet()
Returns a collection view of the mappings contained in this map. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the specified key is mapped in this identity hash map, or null if the map contains no mapping for this key. |
protected ConcurrentHashMap.Entry |
getEntry(java.lang.Object key)
Returns the entry associated with the specified key in the ConcurrentHashMap. |
int |
getMaxSize()
The maximum number of entries, or Integer.MAX_VALUE for no limit. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
boolean |
isFull()
Whether the map is full. |
java.util.Set |
keySet()
Returns a set view of the keys contained in this map. |
float |
loadFactor()
Returns the load factor for this map. |
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 map. |
void |
putAll(java.util.Map t)
Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map. |
java.lang.Object |
putIfAbsent(java.lang.Object key,
java.lang.Object value)
|
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 map if present. |
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. |
java.util.Collection |
values()
Returns a collection view of the values contained in this map. |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public ConcurrentHashMap(int initialCapacity,
float loadFactor)
initialCapacity - The initial capacity.loadFactor - The load factor.
java.lang.IllegalArgumentException - if the initial capacity is negative
or the load factor is nonpositive.public ConcurrentHashMap(int initialCapacity)
initialCapacity - the initial capacity.
java.lang.IllegalArgumentException - if the initial capacity is negative.public ConcurrentHashMap()
public ConcurrentHashMap(java.util.Map m)
m - the map whose mappings are to be placed in this map.
java.lang.NullPointerException - if the specified map is null.| Method Detail |
|---|
public final int capacity()
public final float loadFactor()
public int getMaxSize()
SizedMap
getMaxSize in interface SizedMappublic void setMaxSize(int maxSize)
SizedMap
setMaxSize in interface SizedMappublic boolean isFull()
SizedMap
isFull in interface SizedMap
public void overflowRemoved(java.lang.Object key,
java.lang.Object value)
SizedMap
overflowRemoved in interface SizedMappublic final int size()
size in interface java.util.Mapsize in class java.util.AbstractMappublic final boolean isEmpty()
isEmpty in interface java.util.MapisEmpty in class java.util.AbstractMappublic java.lang.Object get(java.lang.Object key)
get in interface java.util.Mapget in class java.util.AbstractMapkey - the key whose associated value is to be returned.
put(Object, Object)public final boolean containsKey(java.lang.Object key)
containsKey in interface java.util.MapcontainsKey in class java.util.AbstractMapkey - The key whose presence in this map is to be tested
protected ConcurrentHashMap.Entry getEntry(java.lang.Object key)
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
put in interface java.util.Mapput in class java.util.AbstractMapkey - key with which the specified value is to be associated.value - value to be associated with the specified key.
public java.lang.Object putIfAbsent(java.lang.Object key,
java.lang.Object value)
public final void putAll(java.util.Map t)
putAll in interface java.util.MapputAll in class java.util.AbstractMapt - mappings to be stored in this map.
java.lang.NullPointerException - if the specified map is null.public java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mapremove in class java.util.AbstractMapkey - key whose mapping is to be removed from the map.
public void clear()
clear in interface java.util.Mapclear in class java.util.AbstractMappublic java.util.Map.Entry removeRandom()
ConcurrentMap
removeRandom in interface ConcurrentMappublic java.util.Iterator randomEntryIterator()
ConcurrentMap
randomEntryIterator in interface ConcurrentMappublic final boolean containsValue(java.lang.Object value)
containsValue in interface java.util.MapcontainsValue in class java.util.AbstractMapvalue - value whose presence in this map is to be tested.
public final java.lang.Object clone()
clone in class java.util.AbstractMap
protected ConcurrentHashMap.Entry createEntry(int h,
java.lang.Object k,
java.lang.Object v,
ConcurrentHashMap.Entry n)
public final java.util.Set keySet()
keySet in interface java.util.MapkeySet in class java.util.AbstractMappublic final java.util.Collection values()
values in interface java.util.Mapvalues in class java.util.AbstractMappublic final java.util.Set entrySet()
entrySet in interface java.util.MapentrySet in class java.util.AbstractMapConcurrentHashMap.Entry
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||