Top Inners Fields Constructors Methods
org.eclipse.collections.impl.map.mutable

public final Class ConcurrentHashMap<K, V>

extends AbstractMutableMap<K, V>
implements ConcurrentMutableMap<K, V>, Externalizable
Class Inheritance
All Implemented Interfaces
java.io.Externalizable, java.io.Serializable, org.eclipse.collections.api.map.ConcurrentMutableMap, java.util.concurrent.ConcurrentMap, java.util.Map, org.eclipse.collections.api.map.MutableMap, java.lang.Cloneable, org.eclipse.collections.api.map.UnsortedMapIterable, org.eclipse.collections.api.map.MapIterable, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable, java.lang.Iterable, org.eclipse.collections.api.map.MutableMapIterable
Annotations
@SuppressWarnings:rawtypes, ObjectEquality
Imports
java.io.Externalizable, .IOException, .ObjectInput, .ObjectOutput, java.util.AbstractCollection, .AbstractSet, .Collection, .ConcurrentModificationException, .Iterator, .List, .Map, .NoSuchElementException, .Objects, .Set, java.util.concurrent.Executor, .FutureTask, java.util.concurrent.atomic.AtomicInteger, .AtomicIntegerArray, .AtomicIntegerFieldUpdater, .AtomicReferenceArray, .AtomicReferenceFieldUpdater, java.util.function.BiFunction, .Predicate, org.eclipse.collections.api.block.function.Function, .Function0, .Function2, .Function3, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure, org.eclipse.collections.api.factory.Maps, org.eclipse.collections.api.map.ConcurrentMutableMap, .ImmutableMap, .MapIterable, .MutableMap, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.block.procedure.MapEntryToProcedure2, org.eclipse.collections.impl.list.mutable.FastList, org.eclipse.collections.impl.utility.Iterate, .MapIterate, org.eclipse.collections.impl.utility.internal.IterableIterate

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
private class
private abstract class
private static class
private class
private class
private static class
private class
private class

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
MAXIMUM_CAPACITY

The maximum capacity, used if a higher value is implicitly specified by either of the constructors with arguments.

private static final int
private AtomicIntegerArray
private static final Object
private static final Object
private static final Object
private static final long
private volatile int
private static final int
private static final AtomicIntegerFieldUpdater<ConcurrentHashMap<K, V>>
private volatile AtomicReferenceArray<E>
table

The table, resized as necessary.

private static final AtomicReferenceFieldUpdater<ConcurrentHashMap<K, V>, AtomicReferenceArray<E>>

Constructor Summary

AccessConstructor and Description
public
public
ConcurrentHashMap(int initialCapacity)

Method Summary

Modifier and TypeMethod and Description
private void
addToSize(int value)

public void
clear()

Implements java.util.Map.clear.

Removes all of the mappings from this map (optional operation).

public MutableMap<K, V>
clone()

Implements abstract org.eclipse.collections.impl.map.mutable.AbstractMutableMap.clone.

Implements org.eclipse.collections.api.map.MutableMap.clone.

Creates and returns a copy of this object.

public <E> MutableMap<K, V>
collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction)

Implements org.eclipse.collections.api.map.MutableMap.collectKeysAndValues.

Adds all the entries derived from iterable to this.

public boolean
containsKey(Object key)

Implements org.eclipse.collections.api.map.MapIterable.containsKey, java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.

public boolean
containsValue(Object value)

Implements org.eclipse.collections.api.map.MapIterable.containsValue, java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.

private ConcurrentHashMap.Entry<K, V>
public Set<Map.Entry<K, V>>
entrySet()

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

public boolean
public void
forEachKey(Procedure<? super K> procedure)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachKey.

Implements org.eclipse.collections.api.map.MapIterable.forEachKey.

Calls the procedure with each key of the map.

public void
forEachKeyValue(Procedure2<? super K, ? super V> procedure)

Implements org.eclipse.collections.api.map.MapIterable.forEachKeyValue.

Calls the procedure with each key-value pair of the map.

public void
forEachValue(Procedure<? super V> procedure)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachValue.

Implements org.eclipse.collections.api.map.MapIterable.forEachValue.

Calls the procedure with each value of the map.

public <P> void
forEachWith(Procedure2<? super V, ? super P> procedure, P parameter)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachWith.

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

public void
forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.forEachWithIndex.

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

public V
get(Object key)

Implements org.eclipse.collections.api.map.MapIterable.get, java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

private ConcurrentHashMap.Entry<K, V>
public V
getIfAbsent(K key, Function0<? extends V> function)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.getIfAbsent.

Implements org.eclipse.collections.api.map.MapIterable.getIfAbsent.

Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified Function0.

public V
getIfAbsentPut(K key, Function<? super K, ? extends V> factory)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.getIfAbsentPut.

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut.

Get and return the value in the Map at the specified key.

public V
public V
public <P> V
getIfAbsentPutWith(K key, Function<? super P, ? extends V> function, P parameter)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.getIfAbsentPutWith.

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPutWith.

Get and return the value in the Map at the specified key.

public <P> V
getIfAbsentWith(K key, Function<? super P, ? extends V> function, P parameter)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.getIfAbsentWith.

Implements org.eclipse.collections.api.map.MapIterable.getIfAbsentWith.

Return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified function and parameter.

private int
hash(Object key)

public int
private AtomicReferenceArray<E>
private AtomicReferenceArray<E>
public <A> A
ifPresentApply(K key, Function<? super V, ? extends A> function)

Overrides org.eclipse.collections.impl.map.AbstractMapIterable.ifPresentApply.

Implements org.eclipse.collections.api.map.MapIterable.ifPresentApply.

If there is a value in the Map that corresponds to the specified key return the result of applying the specified Function on the value, otherwise return null.

private void
incrementLocalSize(int value)

private boolean
private void
incrementSizeAndPossiblyResize(AtomicReferenceArray<E> currentArray, int length, Object prev)

private static int
indexFor(int h, int length)

public boolean
public Iterator<V>
public Set<K>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.

public V
merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction)

Overrides default java.util.Map.merge.

Implements org.eclipse.collections.api.map.ConcurrentMutableMap.merge.

A concurrent implementation of ConcurrentMap#merge(Object, Object, BiFunction) and Map#merge(Object, Object, BiFunction).

public <K, V> MutableMap<K, V>
newEmpty(int capacity)

Implements abstract org.eclipse.collections.impl.map.mutable.AbstractMutableMap.newEmpty.

Creates a new instance of the same type, using the given capacity and the default growth parameters.

public MutableMap<K, V>
newEmpty()

Implements org.eclipse.collections.api.map.MutableMap.newEmpty, org.eclipse.collections.api.map.MutableMapIterable.newEmpty.

Creates a new instance of the same type, using the default capacity and growth parameters.

public static <K, V> ConcurrentHashMap<K, V>
public static <K, V> ConcurrentHashMap<K, V>
newMap(int newSize)

public static <NK, NV> ConcurrentHashMap<NK, NV>
newMap(Map<NK, NV> map)

public boolean
notEmpty()

Overrides default org.eclipse.collections.api.RichIterable.notEmpty.

The English equivalent of !this.isEmpty()

private boolean
public void
public void
public V
put(K key, V value)

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).

public void
putAll(Map<? extends K, ? extends V> map)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).

public void
putAllInParallel(Map<? extends K, ? extends V> map, int chunks, Executor executor)

public V
putIfAbsent(K key, V value)

Overrides default java.util.Map.putIfAbsent.

Implements java.util.concurrent.ConcurrentMap.putIfAbsent.

If the specified key is not already associated with a value, associates it with the given value.

public <P1, P2> V
putIfAbsentGetIfPresent(K
The "mutable" key, which has the same identity/hashcode as the inserted key, only during this call
key
,
Function2<? super K, ? super V, ? extends K>
If the record is absent, the transformer will transform the "mutable" key into an immutable copy of the key. Note that the transformed key must have the same identity/hashcode as the original "mutable" key.
keyTransformer
,
Function3<P1, P2, ? super K, ? extends V>
It creates an object, if it is not present in the map already.
factory
,
P1 param1, P2 param2)

It puts an object into the map based on the key.

public void
readExternal(ObjectInput in)

Implements java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.

public boolean
remove(Object key, Object value)

Overrides default java.util.Map.remove.

Implements java.util.concurrent.ConcurrentMap.remove.

Removes the entry for a key only if currently mapped to a given value.

public V
remove(Object key)

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).

public V
removeKey(K key)

Implements org.eclipse.collections.api.map.MutableMapIterable.removeKey.

Remove an entry from the map at the specified key.

public boolean
replace(K key, V oldValue, V newValue)

Overrides default java.util.Map.replace.

Implements java.util.concurrent.ConcurrentMap.replace.

Replaces the entry for a key only if currently mapped to a given value.

public V
replace(K key, V value)

Overrides default java.util.Map.replace.

Implements java.util.concurrent.ConcurrentMap.replace.

Replaces the entry for a key only if currently mapped to some value.

private void
private void
resize(AtomicReferenceArray<E> oldTable, int newSize)

private void
private void
sequentialForEachKeyValue(Procedure2<? super K, ? super V> block, AtomicReferenceArray<E> currentArray, int start, int end)

private void
sequentialForEachValue(Procedure<V> block, AtomicReferenceArray<E> currentArray, int start, int end)

private void
sequentialPutAll(AtomicReferenceArray<E> currentArray, int start, int end)

public int
size()

Implements org.eclipse.collections.api.RichIterable.size, java.util.Map.size.

Returns the number of key-value mappings in this map.

private V
slowGet(Object key, int hash, int index, AtomicReferenceArray<E> currentArray)

private V
slowMerge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, int hash, AtomicReferenceArray<E> currentArray)

private V
slowPut(K key, V value, int hash, AtomicReferenceArray<E> currentArray)

private V
slowRemove(Object key, int hash, AtomicReferenceArray<E> currentArray)

private boolean
slowReplace(K key, V oldValue, V newValue, int hash, AtomicReferenceArray<E> currentArray)

private V
slowReplace(K key, V value, int hash, AtomicReferenceArray<E> currentArray)

private V
slowUpdateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function, int hash, AtomicReferenceArray<E> currentArray)

private <P> V
slowUpdateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter, int hash, AtomicReferenceArray<E> currentArray)

public ConcurrentMutableMap<K, V>
public ImmutableMap<K, V>
public String
toString()

Overrides org.eclipse.collections.impl.AbstractRichIterable.toString.

Implements org.eclipse.collections.api.map.MapIterable.toString, org.eclipse.collections.api.RichIterable.toString.

Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces.

private void
private void
public V
updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.updateValue.

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValue.

Looks up the value associated with key, applies the function to it, and replaces the value.

public <P> V
updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.updateValueWith.

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValueWith.

Same as updateValue(Object, Function0, Function) with a Function2 and specified parameter which is passed to the function.

public Collection<V>
values()

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.

public ConcurrentHashMap<K, V>
public ConcurrentHashMap<K, V>
withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withAllKeyValues.

Implements org.eclipse.collections.api.map.MutableMap.withAllKeyValues, org.eclipse.collections.api.map.MutableMapIterable.withAllKeyValues.

This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements.

public ConcurrentHashMap<K, V>
withKeyValue(K key, V value)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withKeyValue.

Implements org.eclipse.collections.api.map.MutableMap.withKeyValue, org.eclipse.collections.api.map.MutableMapIterable.withKeyValue.

This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements.

public ConcurrentHashMap<K, V>
public ConcurrentHashMap<K, V>
public ConcurrentHashMap<K, V>
withoutAllKeys(Iterable<? extends K> keys)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withoutAllKeys.

Implements org.eclipse.collections.api.map.MutableMap.withoutAllKeys, org.eclipse.collections.api.map.MutableMapIterable.withoutAllKeys.

This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements.

public ConcurrentHashMap<K, V>
withoutKey(K key)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withoutKey.

Implements org.eclipse.collections.api.map.MutableMap.withoutKey, org.eclipse.collections.api.map.MutableMapIterable.withoutKey.

This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements.

public void
writeExternal(ObjectOutput out)

Implements java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Inherited from org.eclipse.collections.impl.map.mutable.AbstractMutableMap:
asSynchronizedasUnmodifiablecollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectKeysUniquecollectLongcollectShortcollectValuescollectWithflatCollectflipgroupBygroupByEachgroupByUniqueKeypartitionpartitionWithrejectrejectrejectWithreplaceAllselectselectselectInstancesOfselectWithzipzipWithIndex