public class ConcurrentHashMapUnsafe<K,V> extends AbstractMutableMap<K,V> implements com.gs.collections.api.map.ConcurrentMutableMap<K,V>, java.io.Externalizable
AbstractMutableMap.ValuesCollectionCommon<V>| Constructor and Description |
|---|
ConcurrentHashMapUnsafe() |
ConcurrentHashMapUnsafe(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
com.gs.collections.api.map.MutableMap<K,V> |
clone() |
<E> com.gs.collections.api.map.MutableMap<K,V> |
collectKeysAndValues(java.lang.Iterable<E> iterable,
com.gs.collections.api.block.function.Function<? super E,? extends K> keyFunction,
com.gs.collections.api.block.function.Function<? super E,? extends V> valueFunction)
Adds all the entries derived from
iterable to this. |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
int |
countEntries() |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
boolean |
equals(java.lang.Object o)
Follows the same general contract as
Map.equals(Object). |
void |
forEachKey(com.gs.collections.api.block.procedure.Procedure<? super K> procedure)
Calls the
procedure with each key of the map. |
void |
forEachKeyValue(com.gs.collections.api.block.procedure.Procedure2<? super K,? super V> procedure)
Calls the
procedure with each key-value pair of the map. |
void |
forEachValue(com.gs.collections.api.block.procedure.Procedure<? super V> procedure)
Calls the procedure with each value of the map.
|
<P> void |
forEachWith(com.gs.collections.api.block.procedure.Procedure2<? super V,? super P> procedure,
P parameter)
The procedure2 is evaluated for each element in the iterable with the specified parameter provided
as the second argument.
|
void |
forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super V> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of
ObjectIntProcedure.
|
V |
get(java.lang.Object key) |
V |
getIfAbsent(K key,
com.gs.collections.api.block.function.Function0<? extends V> function)
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.
|
V |
getIfAbsentPut(K key,
com.gs.collections.api.block.function.Function<? super K,? extends V> factory) |
V |
getIfAbsentPut(K key,
com.gs.collections.api.block.function.Function0<? extends V> factory)
Get and return the value in the Map at the specified key.
|
V |
getIfAbsentPut(K key,
V value)
Get and return the value in the Map at the specified key.
|
<P> V |
getIfAbsentPutWith(K key,
com.gs.collections.api.block.function.Function<? super P,? extends V> function,
P parameter)
Get and return the value in the Map at the specified key.
|
<P> V |
getIfAbsentWith(K key,
com.gs.collections.api.block.function.Function<? super P,? extends V> function,
P parameter)
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.
|
int |
hashCode()
Follows the same general contract as
Map.hashCode(). |
<A> A |
ifPresentApply(K key,
com.gs.collections.api.block.function.Function<? super V,? extends A> function)
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.
|
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
java.util.Iterator<V> |
iterator() |
java.util.Set<K> |
keySet() |
com.gs.collections.api.map.MutableMap<K,V> |
newEmpty()
Creates a new instance of the same type, using the default capacity and growth parameters.
|
<K,V> com.gs.collections.api.map.MutableMap<K,V> |
newEmpty(int capacity)
Creates a new instance of the same type, using the given capacity and the default growth parameters.
|
static <K,V> ConcurrentHashMapUnsafe<K,V> |
newMap() |
static <K,V> ConcurrentHashMapUnsafe<K,V> |
newMap(int newSize) |
static <NK,NV> ConcurrentHashMapUnsafe<NK,NV> |
newMap(java.util.Map<NK,NV> map) |
boolean |
notEmpty()
The English equivalent of !this.isEmpty()
|
void |
parallelForEachKeyValue(java.util.List<com.gs.collections.api.block.procedure.Procedure2<K,V>> blocks,
java.util.concurrent.Executor executor) |
void |
parallelForEachValue(java.util.List<com.gs.collections.api.block.procedure.Procedure<V>> blocks,
java.util.concurrent.Executor executor) |
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> map) |
void |
putAllInParallel(java.util.Map<K,V> map,
int chunks,
java.util.concurrent.Executor executor) |
V |
putIfAbsent(K key,
V value) |
<P1,P2> V |
putIfAbsentGetIfPresent(K key,
com.gs.collections.api.block.function.Function2<K,V,K> keyTransformer,
com.gs.collections.api.block.function.Function3<P1,P2,K,V> factory,
P1 param1,
P2 param2)
It puts an object into the map based on the key.
|
void |
readExternal(java.io.ObjectInput in) |
V |
remove(java.lang.Object key) |
boolean |
remove(java.lang.Object key,
java.lang.Object value) |
V |
removeKey(K key)
Remove an entry from the map at the specified
key. |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
int |
size()
Returns the number of items in this iterable.
|
com.gs.collections.api.map.ImmutableMap<K,V> |
toImmutable()
Returns an immutable copy of this map.
|
java.lang.String |
toString()
Returns a string representation of this collection.
|
V |
updateValue(K key,
com.gs.collections.api.block.function.Function0<? extends V> factory,
com.gs.collections.api.block.function.Function<? super V,? extends V> function)
Looks up the value associated with
key, applies the function to it, and replaces the value. |
<P> V |
updateValueWith(K key,
com.gs.collections.api.block.function.Function0<? extends V> factory,
com.gs.collections.api.block.function.Function2<? super V,? super P,? extends V> function,
P parameter)
Same as
MutableMapIterable.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is
passed to the function. |
java.util.Collection<V> |
values() |
ConcurrentHashMapUnsafe<K,V> |
withAllKeyValueArguments(com.gs.collections.api.tuple.Pair<? extends K,? extends V>... keyValues)
Convenience var-args version of withAllKeyValues
|
ConcurrentHashMapUnsafe<K,V> |
withAllKeyValues(java.lang.Iterable<? extends com.gs.collections.api.tuple.Pair<? extends K,? extends V>> keyValues)
This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing
elements.
|
ConcurrentHashMapUnsafe<K,V> |
withKeyValue(K key,
V value)
This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing
elements.
|
ConcurrentHashMapUnsafe<K,V> |
withoutAllKeys(java.lang.Iterable<? extends K> keys)
This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing
elements.
|
ConcurrentHashMapUnsafe<K,V> |
withoutKey(K key)
This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing
elements.
|
void |
writeExternal(java.io.ObjectOutput out) |
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, flatCollect, flip, groupBy, groupByEach, partition, partitionWith, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, tap, zip, zipWithIndexadd, aggregateBy, aggregateInPlaceBy, collect, detect, flipUniqueValues, getIfAbsentPutWithKey, groupByUniqueKey, keysView, keyValuesView, valuesViewallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectWith, detectWithIfNone, each, getFirst, getIfAbsentValue, getLast, isAbsent, keyAndValueEquals, keyAndValueHashCode, noneSatisfy, noneSatisfyWith, toArray, toArrayappendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexfinalize, getClass, notify, notifyAll, wait, wait, waitaggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, collect, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, flatCollect, flip, flipUniqueValues, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, tap, zip, zipWithIndexadd, getIfAbsentPutWithKeydetect, getIfAbsentValue, keysView, keyValuesView, valuesViewallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, flatCollect, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexpublic ConcurrentHashMapUnsafe()
public ConcurrentHashMapUnsafe(int initialCapacity)
public static <K,V> ConcurrentHashMapUnsafe<K,V> newMap()
public static <K,V> ConcurrentHashMapUnsafe<K,V> newMap(int newSize)
public int countEntries()
public V getIfAbsentPut(K key, com.gs.collections.api.block.function.Function<? super K,? extends V> factory)
public V getIfAbsentPut(K key, com.gs.collections.api.block.function.Function0<? extends V> factory)
com.gs.collections.api.map.MutableMapIterablegetIfAbsentPut in interface com.gs.collections.api.map.MutableMapIterable<K,V>getIfAbsentPut in class AbstractMutableMapIterable<K,V>public V getIfAbsentPut(K key, V value)
com.gs.collections.api.map.MutableMapIterablegetIfAbsentPut in interface com.gs.collections.api.map.MutableMapIterable<K,V>getIfAbsentPut in class AbstractMutableMapIterable<K,V>public <P1,P2> V putIfAbsentGetIfPresent(K key, com.gs.collections.api.block.function.Function2<K,V,K> keyTransformer, com.gs.collections.api.block.function.Function3<P1,P2,K,V> factory, P1 param1, P2 param2)
key - The "mutable" key, which has the same identity/hashcode as the inserted key, only during this callkeyTransformer - 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.factory - It creates an object, if it is not present in the map already.public boolean remove(java.lang.Object key,
java.lang.Object value)
public int size()
com.gs.collections.api.RichIterablepublic boolean isEmpty()
com.gs.collections.api.RichIterablepublic boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public V get(java.lang.Object key)
public void putAllInParallel(java.util.Map<K,V> map, int chunks, java.util.concurrent.Executor executor)
public void parallelForEachKeyValue(java.util.List<com.gs.collections.api.block.procedure.Procedure2<K,V>> blocks, java.util.concurrent.Executor executor)
public void parallelForEachValue(java.util.List<com.gs.collections.api.block.procedure.Procedure<V>> blocks, java.util.concurrent.Executor executor)
public int hashCode()
com.gs.collections.api.map.MapIterableMap.hashCode().public boolean equals(java.lang.Object o)
com.gs.collections.api.map.MapIterableMap.equals(Object).public java.lang.String toString()
AbstractRichIterable
This implementation creates an empty string buffer, appends a left square bracket, and iterates over the collection appending the string representation of each element in turn. After appending each element except the last, the string ", " is appended. Finally a right bracket is appended. A string is obtained from the string buffer, and returned.
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic static <NK,NV> ConcurrentHashMapUnsafe<NK,NV> newMap(java.util.Map<NK,NV> map)
public ConcurrentHashMapUnsafe<K,V> withKeyValue(K key, V value)
com.gs.collections.api.map.MutableMapIterable
map = map.withKeyValue("new key", "new value");
In the case of FixedSizeMap, a new instance will be returned by withKeyValue, and any variables that
previously referenced the original map will need to be redirected to reference the new instance. In the case
of a FastMap or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap
will both return "this" after calling put on themselves.withKeyValue in interface com.gs.collections.api.map.MutableMap<K,V>withKeyValue in interface com.gs.collections.api.map.MutableMapIterable<K,V>withKeyValue in class AbstractMutableMap<K,V>Map.put(Object, Object)public ConcurrentHashMapUnsafe<K,V> withAllKeyValues(java.lang.Iterable<? extends com.gs.collections.api.tuple.Pair<? extends K,? extends V>> keyValues)
com.gs.collections.api.map.MutableMapIterable
map = map.withAllKeyValues(FastList.newListWith(PairImpl.of("new key", "new value")));
In the case of FixedSizeMap, a new instance will be returned by withAllKeyValues, and any variables that
previously referenced the original map will need to be redirected to reference the new instance. In the case
of a FastMap or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap
will both return "this" after calling put on themselves.withAllKeyValues in interface com.gs.collections.api.map.MutableMap<K,V>withAllKeyValues in interface com.gs.collections.api.map.MutableMapIterable<K,V>withAllKeyValues in class AbstractMutableMap<K,V>Map.put(Object, Object)public ConcurrentHashMapUnsafe<K,V> withAllKeyValueArguments(com.gs.collections.api.tuple.Pair<? extends K,? extends V>... keyValues)
com.gs.collections.api.map.MutableMapIterablewithAllKeyValueArguments in interface com.gs.collections.api.map.MutableMap<K,V>withAllKeyValueArguments in interface com.gs.collections.api.map.MutableMapIterable<K,V>withAllKeyValueArguments in class AbstractMutableMap<K,V>MutableMapIterable.withAllKeyValues(Iterable)public ConcurrentHashMapUnsafe<K,V> withoutKey(K key)
com.gs.collections.api.map.MutableMapIterable
map = map.withoutKey("key");
In the case of FixedSizeMap, a new instance will be returned by withoutKey, and any variables that previously
referenced the original map will need to be redirected to reference the new instance. In the case of a FastMap
or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap will both return
"this" after calling remove on themselves.withoutKey in interface com.gs.collections.api.map.MutableMap<K,V>withoutKey in interface com.gs.collections.api.map.MutableMapIterable<K,V>withoutKey in class AbstractMutableMap<K,V>Map.remove(Object)public ConcurrentHashMapUnsafe<K,V> withoutAllKeys(java.lang.Iterable<? extends K> keys)
com.gs.collections.api.map.MutableMapIterable
map = map.withoutAllKeys(FastList.newListWith("key1", "key2"));
In the case of FixedSizeMap, a new instance will be returned by withoutAllKeys, and any variables that previously
referenced the original map will need to be redirected to reference the new instance. In the case of a FastMap
or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap will both return
"this" after calling remove on themselves.withoutAllKeys in interface com.gs.collections.api.map.MutableMap<K,V>withoutAllKeys in interface com.gs.collections.api.map.MutableMapIterable<K,V>withoutAllKeys in class AbstractMutableMap<K,V>Map.remove(Object)public <K,V> com.gs.collections.api.map.MutableMap<K,V> newEmpty(int capacity)
AbstractMutableMapnewEmpty in class AbstractMutableMap<K,V>public boolean notEmpty()
com.gs.collections.api.RichIterablenotEmpty in interface com.gs.collections.api.RichIterable<V>notEmpty in class AbstractRichIterable<V>public void forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super V> objectIntProcedure)
com.gs.collections.api.InternalIterableExample using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
forEachWithIndex in interface com.gs.collections.api.InternalIterable<V>forEachWithIndex in class AbstractMapIterable<K,V>public java.util.Iterator<V> iterator()
iterator in interface java.lang.Iterable<V>iterator in class AbstractMutableMapIterable<K,V>public com.gs.collections.api.map.MutableMap<K,V> newEmpty()
com.gs.collections.api.map.MutableMapIterablepublic void forEachValue(com.gs.collections.api.block.procedure.Procedure<? super V> procedure)
com.gs.collections.api.map.MapIterable
Set<String> result = UnifiedSet.newSet();
MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three", 4, "Four");
map.forEachValue(new CollectionAddProcedure<String>(result));
Verify.assertSetsEqual(UnifiedSet.newSetWith("One", "Two", "Three", "Four"), result);
forEachValue in interface com.gs.collections.api.map.MapIterable<K,V>forEachValue in class AbstractMapIterable<K,V>public void forEachKey(com.gs.collections.api.block.procedure.Procedure<? super K> procedure)
com.gs.collections.api.map.MapIterableprocedure with each key of the map.
final Collection<Integer> result = new ArrayList<Integer>();
MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
map.forEachKey(new CollectionAddProcedure<Integer>(result));
Verify.assertContainsAll(result, 1, 2, 3);
forEachKey in interface com.gs.collections.api.map.MapIterable<K,V>forEachKey in class AbstractMapIterable<K,V>public void forEachKeyValue(com.gs.collections.api.block.procedure.Procedure2<? super K,? super V> procedure)
com.gs.collections.api.map.MapIterableprocedure with each key-value pair of the map.
final Collection<String> collection = new ArrayList<String>();
MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three");
map.forEachKeyValue(new Procedure2<Integer, String>()
{
public void value(final Integer key, final String value)
{
collection.add(String.valueOf(key) + value);
}
});
Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
public <E> com.gs.collections.api.map.MutableMap<K,V> collectKeysAndValues(java.lang.Iterable<E> iterable, com.gs.collections.api.block.function.Function<? super E,? extends K> keyFunction, com.gs.collections.api.block.function.Function<? super E,? extends V> valueFunction)
com.gs.collections.api.map.MutableMapiterable to this. The key and value for each entry
is determined by applying the keyFunction and valueFunction to each item in
collection. Any entry in map that has the same key as an entry in this
will have its value replaced by that in map.public V removeKey(K key)
com.gs.collections.api.map.MutableMapIterablekey.public <P> V getIfAbsentPutWith(K key, com.gs.collections.api.block.function.Function<? super P,? extends V> function, P parameter)
com.gs.collections.api.map.MutableMapIterablegetIfAbsentPutWith in interface com.gs.collections.api.map.MutableMapIterable<K,V>getIfAbsentPutWith in class AbstractMutableMapIterable<K,V>public V getIfAbsent(K key, com.gs.collections.api.block.function.Function0<? extends V> function)
com.gs.collections.api.map.MapIterablegetIfAbsent in interface com.gs.collections.api.map.MapIterable<K,V>getIfAbsent in class AbstractMapIterable<K,V>public <P> V getIfAbsentWith(K key, com.gs.collections.api.block.function.Function<? super P,? extends V> function, P parameter)
com.gs.collections.api.map.MapIterablegetIfAbsentWith in interface com.gs.collections.api.map.MapIterable<K,V>getIfAbsentWith in class AbstractMapIterable<K,V>public <A> A ifPresentApply(K key, com.gs.collections.api.block.function.Function<? super V,? extends A> function)
com.gs.collections.api.map.MapIterableifPresentApply in interface com.gs.collections.api.map.MapIterable<K,V>ifPresentApply in class AbstractMapIterable<K,V>public <P> void forEachWith(com.gs.collections.api.block.procedure.Procedure2<? super V,? super P> procedure, P parameter)
com.gs.collections.api.InternalIterableExample using a Java 8 lambda:
people.forEachWith((Person person, Person other) ->
{
if (person.isRelatedTo(other))
{
LOGGER.info(person.getName());
}
}, fred);
Example using an anonymous inner class:
people.forEachWith(new Procedure2() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);
forEachWith in interface com.gs.collections.api.InternalIterable<V>forEachWith in class AbstractMapIterable<K,V>public V updateValue(K key, com.gs.collections.api.block.function.Function0<? extends V> factory, com.gs.collections.api.block.function.Function<? super V,? extends V> function)
com.gs.collections.api.map.MutableMapIterablekey, applies the function to it, and replaces the value. If there
is no value associated with key, starts it off with a value supplied by factory.updateValue in interface com.gs.collections.api.map.MutableMapIterable<K,V>updateValue in class AbstractMutableMapIterable<K,V>public <P> V updateValueWith(K key, com.gs.collections.api.block.function.Function0<? extends V> factory, com.gs.collections.api.block.function.Function2<? super V,? super P,? extends V> function, P parameter)
com.gs.collections.api.map.MutableMapIterableMutableMapIterable.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is
passed to the function.updateValueWith in interface com.gs.collections.api.map.MutableMapIterable<K,V>updateValueWith in class AbstractMutableMapIterable<K,V>public com.gs.collections.api.map.ImmutableMap<K,V> toImmutable()
com.gs.collections.api.map.MutableMapIterabletoImmutable in interface com.gs.collections.api.map.MapIterable<K,V>toImmutable in interface com.gs.collections.api.map.MutableMapIterable<K,V>toImmutable in interface com.gs.collections.api.map.UnsortedMapIterable<K,V>toImmutable in class AbstractMutableMap<K,V>