|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap
org.norther.tammi.acorn.util.ConcurrentAbstractMap
public abstract class ConcurrentAbstractMap
An abstract class implementing the ConcurrentMap interface and
supporting thread-safe concurrent access with less synchronization than
Hashtable.
Iterators and Enumerations return elements reflecting the state of the map at some point at or since the creation of the iterator/enumeration. They do not throw ConcurrentModificationException.
This class allows null to be used as a key or value.
Based on Doug Lea's ConcurrentHashMap .
| Nested Class Summary | |
|---|---|
protected static class |
ConcurrentAbstractMap.Entry
An inner class for chained hash lists. |
| Field Summary | |
|---|---|
protected static float |
DEFAULT_LOAD_FACTOR
The default load factor. |
| Constructor Summary | |
|---|---|
ConcurrentAbstractMap(int capacity,
float factor)
Constructs a new, empty map with the specified initial capacity and the specified load factor. |
|
ConcurrentAbstractMap(Map map)
Constructs a new map with the same mappings as the given map. |
|
| Method Summary | |
|---|---|
boolean |
add(Object key,
Object value)
Associates the specified value with the specified key in this map if not already mapped. |
protected abstract int |
capacity(int capacity)
Returns the appropriate capacity for the expected maximum capacity. |
protected static int |
capacity(int capacity,
int minimum,
int maximum)
Returns the appropriate capacity within the specified limits. |
protected Object |
clone()
|
boolean |
contains(Object value)
Returns true if this map maps one or more keys to the specified value. |
Enumeration |
elements()
Returns an enumeration of the values in this table. |
Set |
entrySet()
Returns a collection view of the mappings contained in this map. |
Object |
get(Object key)
|
protected abstract ConcurrentAbstractMap.Entry |
getEntry(Object key)
Gets the internal entry mapped to the specified key. |
protected abstract Object |
getInternal(Object key)
Gets the internal value mapped to the specified key. |
protected abstract ConcurrentAbstractMap.Entry[] |
getReadTable()
Gets the internal read table. |
protected abstract ConcurrentAbstractMap.Entry[] |
getWriteTable()
Gets the internal write table. |
protected static int |
hash(Object o)
Returns an improved hash code for an object. |
Enumeration |
keys()
Returns an enumeration of the keys in this table. |
Set |
keySet()
Returns a set view of the keys contained in this map. |
Object |
put(Object key,
Object value)
|
Object |
putIfAbsent(Object key,
Object value)
|
protected abstract Object |
putInternal(Object key,
Object value,
boolean r)
Puts the internal value mapped to the specified key. |
Object |
remove(Object key)
|
boolean |
remove(Object key,
Object value)
|
protected abstract Object |
removeInternal(Object key,
Object value)
Removes the internal mapping with the optional value. |
Object |
replace(Object key,
Object value)
|
boolean |
replace(Object key,
Object oldValue,
Object newValue)
|
protected abstract Object |
replaceInternal(Object key,
Object oldValue,
Object newValue)
Replaces the internal value mapped to the specified key with the optional value. |
protected abstract void |
setWriteTable(ConcurrentAbstractMap.Entry[] tab)
Sets the internal write table. |
Collection |
values()
Returns a collection view of the values contained in this map. |
| Methods inherited from class java.util.AbstractMap |
|---|
clear, containsKey, containsValue, equals, hashCode, isEmpty, putAll, size, 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, equals, hashCode, isEmpty, putAll, size |
| Field Detail |
|---|
protected static final float DEFAULT_LOAD_FACTOR
| Constructor Detail |
|---|
public ConcurrentAbstractMap(int capacity,
float factor)
Note that the initial capacity will be rounded to the nearest power of two.
capacity - the initial capacity.factor - the load factor of the map.
IllegalArgumentException - for negative values.public ConcurrentAbstractMap(Map map)
map - the map to copy.| Method Detail |
|---|
protected static final int hash(Object o)
o - the object.
protected static final int capacity(int capacity,
int minimum,
int maximum)
capacity - the desired capacity.minimum - the minimum capacity.maximum - the maximum capacity.
public Object get(Object key)
get in interface Mapget in class AbstractMap
public Object put(Object key,
Object value)
put in interface Mapput in class AbstractMap
public Object putIfAbsent(Object key,
Object value)
putIfAbsent in interface ConcurrentMap
public Object replace(Object key,
Object value)
replace in interface ConcurrentMap
public boolean replace(Object key,
Object oldValue,
Object newValue)
replace in interface ConcurrentMappublic Object remove(Object key)
remove in interface Mapremove in class AbstractMap
public boolean remove(Object key,
Object value)
remove in interface ConcurrentMappublic Set keySet()
keySet in interface MapkeySet in class AbstractMappublic Collection values()
values in interface Mapvalues in class AbstractMappublic Set entrySet()
entrySet in interface MapentrySet in class AbstractMappublic Enumeration keys()
public Enumeration elements()
public boolean contains(Object value)
value - value whose presence in this map is to be tested.
public boolean add(Object key,
Object value)
key - key with which the specified value is to be associated.value - value to be associated with the specified key.
protected Object clone()
throws CloneNotSupportedException
clone in class AbstractMapCloneNotSupportedExceptionprotected abstract int capacity(int capacity)
capacity - the desired capacity.
protected abstract ConcurrentAbstractMap.Entry[] getReadTable()
protected abstract ConcurrentAbstractMap.Entry[] getWriteTable()
protected abstract void setWriteTable(ConcurrentAbstractMap.Entry[] tab)
tab - the write table.protected abstract ConcurrentAbstractMap.Entry getEntry(Object key)
key - the key.
protected abstract Object getInternal(Object key)
key - the key.
protected abstract Object putInternal(Object key,
Object value,
boolean r)
key - the key.value - the value.r - if true, replace an existing mapping.
protected abstract Object replaceInternal(Object key,
Object oldValue,
Object newValue)
key - the key.oldValue - the old value.newValue - the new value.
protected abstract Object removeInternal(Object key,
Object value)
key - the key.value - the value.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||