|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap
groovyx.gpars.extra166y.CustomConcurrentHashMap
public class CustomConcurrentHashMap extends java.util.AbstractMap
A {
- the type of keys maintained by this map
- the type of mapped valuesField Summary | |
---|---|
static CustomConcurrentHashMap.Equivalence |
EQUALS
An Equivalence object performing java.lang.Object#equals based comparisons and using java.lang.Object#hashCode hashing |
static CustomConcurrentHashMap.Equivalence |
IDENTITY
An Equivalence object performing identity-based comparisons and using java.lang.System#identityHashCode for hashing |
private static java.lang.String |
INT_STRING
Config string for int maps |
static int |
MAX_SEGMENT_CAPACITY
|
static int |
MIN_SEGMENT_CAPACITY
|
static int |
NSEGMENTS
|
static int |
SEGMENT_BITS
|
static int |
SEGMENT_MASK
|
static int |
SEGMENT_SHIFT
|
private static java.lang.String |
SELF_STRING
Config string for self-map (Set view) refs |
static CustomConcurrentHashMap.Strength |
SOFT
The strength of soft references |
static CustomConcurrentHashMap.Strength |
STRONG
The strength of ordinary references |
static sun.misc.Unsafe |
UNSAFE
|
static CustomConcurrentHashMap.Strength |
WEAK
The strength of weak references |
java.util.Set |
entrySet
|
CustomConcurrentHashMap.NodeFactory |
factory
|
int |
initialSegmentCapacity
|
CustomConcurrentHashMap.Equivalence |
keyEquivalence
|
java.util.Set |
keySet
|
static java.lang.ref.ReferenceQueue |
refQueue
|
CustomConcurrentHashMap.Segment[] |
segments
The segments, each of which acts as a hash table |
static long |
segmentsBase
|
static int |
segmentsShift
|
private static long |
serialVersionUID
|
static long |
tableBase
|
static int |
tableShift
|
CustomConcurrentHashMap.Equivalence |
valueEquivalence
|
java.util.Collection |
values
|
Constructor Summary | |
CustomConcurrentHashMap()
|
Method Summary | |
---|---|
java.lang.Object
|
CustomConcurrentHashMap(java.lang.String ks, CustomConcurrentHashMap.Equivalence keq, java.lang.String vs, CustomConcurrentHashMap.Equivalence veq, int expectedSize)
|
java.lang.Object
|
CustomConcurrentHashMap(CustomConcurrentHashMap.Strength keyStrength, CustomConcurrentHashMap.Equivalence keyEquivalence, CustomConcurrentHashMap.Strength valueStrength, CustomConcurrentHashMap.Equivalence valueEquivalence, int expectedSize)
Creates a new CustomConcurrentHashMap with the given parameters. |
java.lang.Object
|
CustomConcurrentHashMap()
|
void
|
clear()
Removes all of the mappings from this map. |
java.lang.Object
|
compute(java.lang.Object key, CustomConcurrentHashMap.RemappingFunction remappingFunction)
Updates the mapping for the given key with the result of the given remappingFunction. |
java.lang.Object
|
computeIfAbsent(java.lang.Object key, CustomConcurrentHashMap.MappingFunction mappingFunction)
|
boolean
|
containsKey(java.lang.Object key)
Returns true if this map contains a key equivalent to the given key with respect to this map's key Equivalence. |
boolean
|
containsValue(java.lang.Object value)
|
java.lang.Object
|
doPut(java.lang.Object key, java.lang.Object value, boolean onlyIfNull)
|
java.util.Set
|
entrySet()
Compares the specified object with this map for equality. |
boolean
|
equals(java.lang.Object o)
|
CustomConcurrentHashMap.Node
|
findNode(java.lang.Object key, int hash, CustomConcurrentHashMap.Segment seg)
Returns node for key, or null if none. |
java.lang.Object
|
get(java.lang.Object key)
|
static java.lang.ref.ReferenceQueue
|
getReclamationQueue()
|
CustomConcurrentHashMap.Segment
|
getSegmentForAdd(int hash)
|
CustomConcurrentHashMap.Segment
|
getSegmentForTraversal(int hash)
Returns the segment for possibly inserting into the table associated with given hash, constructing it if necessary. |
private static sun.misc.Unsafe
|
getUnsafe()
|
int
|
hashCode()
Returns the sum of the hash codes of each entry in this map's entrySet() view, which in turn are the hash codes computed using key and value Equivalences for this Map. |
boolean
|
isEmpty()
Returns true if this map contains no key-value mappings. |
CustomConcurrentHashMap.KeyIterator
|
keyIterator()
|
java.util.Set
|
keySet()
Returns a java.util.Collection view of the values contained in this map. |
static CustomConcurrentHashMap
|
newIntKeyIntValueMap(int expectedSize)
|
static CustomConcurrentHashMap
|
newIntKeyMap(CustomConcurrentHashMap.Strength valueStrength, CustomConcurrentHashMap.Equivalence valueEquivalence, int expectedSize)
|
static CustomConcurrentHashMap
|
newIntValueMap(CustomConcurrentHashMap.Strength keyStrength, CustomConcurrentHashMap.Equivalence keyEquivalence, int expectedSize)
|
java.lang.Object
|
put(java.lang.Object key, java.lang.Object value)
Maps the specified key to the specified value in this map. |
void
|
putAll(java.util.Map m)
{@inheritDoc} |
java.lang.Object
|
putIfAbsent(java.lang.Object key, java.lang.Object value)
Copies all of the mappings from the specified map to this one. |
private void
|
readObject(java.io.ObjectInputStream s)
A hash-based set with properties identical to those of Collections.newSetFromMap applied to a CustomConcurrentHashMap, but possibly more space-efficient. |
java.lang.Object
|
remove(java.lang.Object key)
Removes the mapping for the specified key. |
boolean
|
remove(java.lang.Object key, java.lang.Object value)
{@inheritDoc} |
void
|
removeIfReclaimed(CustomConcurrentHashMap.Node r)
Removes node if its key or value are null. |
java.lang.Object
|
replace(java.lang.Object key, java.lang.Object value)
|
boolean
|
replace(java.lang.Object key, java.lang.Object oldValue, java.lang.Object newValue)
{@inheritDoc} |
int
|
size()
|
static int
|
spreadHash(int h)
|
static java.lang.ref.ReferenceQueue
|
startReclamation()
|
static void
|
storeNode(CustomConcurrentHashMap.Node[] table, int i, CustomConcurrentHashMap.Node r)
|
static void
|
storeSegment(CustomConcurrentHashMap.Segment[] segs, int i, CustomConcurrentHashMap.Segment s)
|
CustomConcurrentHashMap
|
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. |
CustomConcurrentHashMap[]
|
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
java.util.Collection
|
values()
Returns a java.util.Set view of the mappings contained in this map. |
private void
|
writeObject(java.io.ObjectOutputStream s)
Reconstitutes the instance from a stream (that is, deserializes it). |
Methods inherited from class java.util.AbstractMap | |
---|---|
java.util.AbstractMap#get(java.lang.Object), java.util.AbstractMap#put(java.lang.Object, java.lang.Object), java.util.AbstractMap#equals(java.lang.Object), java.util.AbstractMap#toString(), java.util.AbstractMap#values(), java.util.AbstractMap#hashCode(), java.util.AbstractMap#clear(), java.util.AbstractMap#isEmpty(), java.util.AbstractMap#entrySet(), java.util.AbstractMap#putAll(java.util.Map), java.util.AbstractMap#size(), java.util.AbstractMap#remove(java.lang.Object), java.util.AbstractMap#keySet(), java.util.AbstractMap#containsKey(java.lang.Object), java.util.AbstractMap#containsValue(java.lang.Object), java.util.AbstractMap#wait(long), java.util.AbstractMap#wait(), java.util.AbstractMap#wait(long, int), java.util.AbstractMap#getClass(), java.util.AbstractMap#notify(), java.util.AbstractMap#notifyAll() |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public static final CustomConcurrentHashMap.Equivalence EQUALS
public static final CustomConcurrentHashMap.Equivalence IDENTITY
private static final java.lang.String INT_STRING
static final int MAX_SEGMENT_CAPACITY
static final int MIN_SEGMENT_CAPACITY
static final int NSEGMENTS
static final int SEGMENT_BITS
static final int SEGMENT_MASK
static final int SEGMENT_SHIFT
private static final java.lang.String SELF_STRING
public static final CustomConcurrentHashMap.Strength SOFT
public static final CustomConcurrentHashMap.Strength STRONG
static final sun.misc.Unsafe UNSAFE
public static final CustomConcurrentHashMap.Strength WEAK
java.util.Set entrySet
final CustomConcurrentHashMap.NodeFactory factory
final int initialSegmentCapacity
final CustomConcurrentHashMap.Equivalence keyEquivalence
java.util.Set keySet
static java.lang.ref.ReferenceQueue refQueue
CustomConcurrentHashMap.Segment[] segments
static final long segmentsBase
static final int segmentsShift
private static final long serialVersionUID
static final long tableBase
static final int tableShift
final CustomConcurrentHashMap.Equivalence valueEquivalence
java.util.Collection values
Constructor Detail |
---|
CustomConcurrentHashMap()
Method Detail |
---|
java.lang.Object CustomConcurrentHashMap(java.lang.String ks, CustomConcurrentHashMap.Equivalence keq, java.lang.String vs, CustomConcurrentHashMap.Equivalence veq, int expectedSize)
public java.lang.Object CustomConcurrentHashMap(CustomConcurrentHashMap.Strength keyStrength, CustomConcurrentHashMap.Equivalence keyEquivalence, CustomConcurrentHashMap.Strength valueStrength, CustomConcurrentHashMap.Equivalence valueEquivalence, int expectedSize)
keyStrength
- the strength for keyskeyEquivalence
- the Equivalence to use for keysvalueStrength
- the strength for valuesvalueEquivalence
- the Equivalence to use for valuesexpectedSize
- an estimate of the number of elements
that will be held in the map. If no estimate is known,
zero is an acceptable value.
public java.lang.Object CustomConcurrentHashMap()
public final void clear()
public java.lang.Object compute(java.lang.Object key, CustomConcurrentHashMap.RemappingFunction remappingFunction)
value = remappingFunction.remap(key, get(key)); if (value != null) return put(key, value): else return remove(key);except that the action is performed atomically. Some attempted operations on this map by other threads may be blocked while computation is in progress.
Sample Usage. A remapping function can be used to perform frequency counting of words using code such as:
map.compute(word, new RemappingFunction<String,Integer>() { public Integer remap(String k, Integer v) { return (v == null) ? 1 : v + 1; }});
key
- key with which the specified value is to be associatedremappingFunction
- the function to compute a value
public java.lang.Object computeIfAbsent(java.lang.Object key, CustomConcurrentHashMap.MappingFunction mappingFunction)
public boolean containsKey(java.lang.Object key)
key
- possible key
public final boolean containsValue(java.lang.Object value)
final java.lang.Object doPut(java.lang.Object key, java.lang.Object value, boolean onlyIfNull)
public java.util.Set entrySet()
o
- object to be compared for equality with this map
public boolean equals(java.lang.Object o)
final CustomConcurrentHashMap.Node findNode(java.lang.Object key, int hash, CustomConcurrentHashMap.Segment seg)
public java.lang.Object get(java.lang.Object key)
static java.lang.ref.ReferenceQueue getReclamationQueue()
final CustomConcurrentHashMap.Segment getSegmentForAdd(int hash)
final CustomConcurrentHashMap.Segment getSegmentForTraversal(int hash)
hash
- the hash code for the key
private static sun.misc.Unsafe getUnsafe()
public int hashCode()
public final boolean isEmpty()
final CustomConcurrentHashMap.KeyIterator keyIterator()
public java.util.Set keySet()
The view's iterator is a "weakly consistent" iterator that will never throw java.util.ConcurrentModificationException, and guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.
public static CustomConcurrentHashMap newIntKeyIntValueMap(int expectedSize)
public static CustomConcurrentHashMap newIntKeyMap(CustomConcurrentHashMap.Strength valueStrength, CustomConcurrentHashMap.Equivalence valueEquivalence, int expectedSize)
public static CustomConcurrentHashMap newIntValueMap(CustomConcurrentHashMap.Strength keyStrength, CustomConcurrentHashMap.Equivalence keyEquivalence, int expectedSize)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key
public void putAll(java.util.Map m)
public java.lang.Object putIfAbsent(java.lang.Object key, java.lang.Object value)
m
- mappings to be stored in this map
private void readObject(java.io.ObjectInputStream s)
public java.lang.Object remove(java.lang.Object key)
key
- the key to remove
public boolean remove(java.lang.Object key, java.lang.Object value)
final void removeIfReclaimed(CustomConcurrentHashMap.Node r)
public java.lang.Object replace(java.lang.Object key, java.lang.Object value)
public boolean replace(java.lang.Object key, java.lang.Object oldValue, java.lang.Object newValue)
public final int size()
static int spreadHash(int h)
static java.lang.ref.ReferenceQueue startReclamation()
static final void storeNode(CustomConcurrentHashMap.Node[] table, int i, CustomConcurrentHashMap.Node r)
static final void storeSegment(CustomConcurrentHashMap.Segment[] segs, int i, CustomConcurrentHashMap.Segment s)
CustomConcurrentHashMap valueOf(java.lang.String name)
CustomConcurrentHashMap[] values()
public java.util.Collection values()
The view's iterator is a "weakly consistent" iterator that will never throw java.util.ConcurrentModificationException, and guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.
private void writeObject(java.io.ObjectOutputStream s)
s
- the stream
Copyright © 2008–2013 Václav Pech. All Rights Reserved.