src/share/classes/java/util/concurrent/ConcurrentHashMap.java
Print this page
@@ -2608,10 +2608,12 @@
/**
* Creates a new {@link Set} backed by a ConcurrentHashMap
* from the given type to {@code Boolean.TRUE}.
*
* @return the new set
+ *
+ * @since 1.8
*/
public static <K> KeySetView<K,Boolean> newKeySet() {
return new KeySetView<K,Boolean>
(new ConcurrentHashMap<K,Boolean>(), Boolean.TRUE);
}
@@ -2623,10 +2625,12 @@
* @param initialCapacity The implementation performs internal
* sizing to accommodate this many elements.
* @throws IllegalArgumentException if the initial capacity of
* elements is negative
* @return the new set
+ *
+ * @since 1.8
*/
public static <K> KeySetView<K,Boolean> newKeySet(int initialCapacity) {
return new KeySetView<K,Boolean>
(new ConcurrentHashMap<K,Boolean>(initialCapacity), Boolean.TRUE);
}
@@ -2660,10 +2664,12 @@
* contain more mappings than can be represented as an int. The
* value returned is an estimate; the actual count may differ if
* there are concurrent insertions or removals.
*
* @return the number of mappings
+ *
+ * @since 1.8
*/
public long mappingCount() {
long n = sumCount();
return (n < 0L) ? 0L : n; // ignore transient negative values
}
@@ -3329,10 +3335,12 @@
* Performs the given action for each (key, value).
*
* @param parallelismThreshold the (estimated) number of elements
* needed for this operation to be executed in parallel
* @param action the action
+ *
+ * @since 1.8
*/
public void forEach(long parallelismThreshold,
BiConsumer<? super K,? super V> action) {
if (action == null) throw new NullPointerException();
new ForEachMappingTask<K,V>
@@ -3348,10 +3356,12 @@
* needed for this operation to be executed in parallel
* @param transformer a function returning the transformation
* for an element, or null if there is no transformation (in
* which case the action is not applied)
* @param action the action
+ *
+ * @since 1.8
*/
public <U> void forEach(long parallelismThreshold,
BiFunction<? super K, ? super V, ? extends U> transformer,
Consumer<? super U> action) {
if (transformer == null || action == null)
@@ -3372,10 +3382,12 @@
* needed for this operation to be executed in parallel
* @param searchFunction a function returning a non-null
* result on success, else null
* @return a non-null result from applying the given search
* function on each (key, value), or null if none
+ *
+ * @since 1.8
*/
public <U> U search(long parallelismThreshold,
BiFunction<? super K, ? super V, ? extends U> searchFunction) {
if (searchFunction == null) throw new NullPointerException();
return new SearchMappingsTask<K,V,U>
@@ -3394,10 +3406,12 @@
* for an element, or null if there is no transformation (in
* which case it is not combined)
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all (key, value) pairs
+ *
+ * @since 1.8
*/
public <U> U reduce(long parallelismThreshold,
BiFunction<? super K, ? super V, ? extends U> transformer,
BiFunction<? super U, ? super U, ? extends U> reducer) {
if (transformer == null || reducer == null)
@@ -3418,10 +3432,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all (key, value) pairs
+ *
+ * @since 1.8
*/
public double reduceToDoubleIn(long parallelismThreshold,
ToDoubleBiFunction<? super K, ? super V> transformer,
double basis,
DoubleBinaryOperator reducer) {
@@ -3443,10 +3459,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all (key, value) pairs
+ *
+ * @since 1.8
*/
public long reduceToLong(long parallelismThreshold,
ToLongBiFunction<? super K, ? super V> transformer,
long basis,
LongBinaryOperator reducer) {
@@ -3468,10 +3486,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all (key, value) pairs
+ *
+ * @since 1.8
*/
public int reduceToInt(long parallelismThreshold,
ToIntBiFunction<? super K, ? super V> transformer,
int basis,
IntBinaryOperator reducer) {
@@ -3486,10 +3506,12 @@
* Performs the given action for each key.
*
* @param parallelismThreshold the (estimated) number of elements
* needed for this operation to be executed in parallel
* @param action the action
+ *
+ * @since 1.8
*/
public void forEachKey(long parallelismThreshold,
Consumer<? super K> action) {
if (action == null) throw new NullPointerException();
new ForEachKeyTask<K,V>
@@ -3505,10 +3527,12 @@
* needed for this operation to be executed in parallel
* @param transformer a function returning the transformation
* for an element, or null if there is no transformation (in
* which case the action is not applied)
* @param action the action
+ *
+ * @since 1.8
*/
public <U> void forEachKey(long parallelismThreshold,
Function<? super K, ? extends U> transformer,
Consumer<? super U> action) {
if (transformer == null || action == null)
@@ -3529,10 +3553,12 @@
* needed for this operation to be executed in parallel
* @param searchFunction a function returning a non-null
* result on success, else null
* @return a non-null result from applying the given search
* function on each key, or null if none
+ *
+ * @since 1.8
*/
public <U> U searchKeys(long parallelismThreshold,
Function<? super K, ? extends U> searchFunction) {
if (searchFunction == null) throw new NullPointerException();
return new SearchKeysTask<K,V,U>
@@ -3547,10 +3573,12 @@
* @param parallelismThreshold the (estimated) number of elements
* needed for this operation to be executed in parallel
* @param reducer a commutative associative combining function
* @return the result of accumulating all keys using the given
* reducer to combine values, or null if none
+ *
+ * @since 1.8
*/
public K reduceKeys(long parallelismThreshold,
BiFunction<? super K, ? super K, ? extends K> reducer) {
if (reducer == null) throw new NullPointerException();
return new ReduceKeysTask<K,V>
@@ -3569,10 +3597,12 @@
* for an element, or null if there is no transformation (in
* which case it is not combined)
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all keys
+ *
+ * @since 1.8
*/
public <U> U reduceKeys(long parallelismThreshold,
Function<? super K, ? extends U> transformer,
BiFunction<? super U, ? super U, ? extends U> reducer) {
if (transformer == null || reducer == null)
@@ -3593,10 +3623,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all keys
+ *
+ * @since 1.8
*/
public double reduceKeysToDouble(long parallelismThreshold,
ToDoubleFunction<? super K> transformer,
double basis,
DoubleBinaryOperator reducer) {
@@ -3618,10 +3650,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all keys
+ *
+ * @since 1.8
*/
public long reduceKeysToLong(long parallelismThreshold,
ToLongFunction<? super K> transformer,
long basis,
LongBinaryOperator reducer) {
@@ -3643,10 +3677,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all keys
+ *
+ * @since 1.8
*/
public int reduceKeysToInt(long parallelismThreshold,
ToIntFunction<? super K> transformer,
int basis,
IntBinaryOperator reducer) {
@@ -3661,10 +3697,12 @@
* Performs the given action for each value.
*
* @param parallelismThreshold the (estimated) number of elements
* needed for this operation to be executed in parallel
* @param action the action
+ *
+ * @since 1.8
*/
public void forEachValue(long parallelismThreshold,
Consumer<? super V> action) {
if (action == null)
throw new NullPointerException();
@@ -3681,10 +3719,12 @@
* needed for this operation to be executed in parallel
* @param transformer a function returning the transformation
* for an element, or null if there is no transformation (in
* which case the action is not applied)
* @param action the action
+ *
+ * @since 1.8
*/
public <U> void forEachValue(long parallelismThreshold,
Function<? super V, ? extends U> transformer,
Consumer<? super U> action) {
if (transformer == null || action == null)
@@ -3705,10 +3745,12 @@
* needed for this operation to be executed in parallel
* @param searchFunction a function returning a non-null
* result on success, else null
* @return a non-null result from applying the given search
* function on each value, or null if none
+ *
+ * @since 1.8
*/
public <U> U searchValues(long parallelismThreshold,
Function<? super V, ? extends U> searchFunction) {
if (searchFunction == null) throw new NullPointerException();
return new SearchValuesTask<K,V,U>
@@ -3722,10 +3764,12 @@
*
* @param parallelismThreshold the (estimated) number of elements
* needed for this operation to be executed in parallel
* @param reducer a commutative associative combining function
* @return the result of accumulating all values
+ *
+ * @since 1.8
*/
public V reduceValues(long parallelismThreshold,
BiFunction<? super V, ? super V, ? extends V> reducer) {
if (reducer == null) throw new NullPointerException();
return new ReduceValuesTask<K,V>
@@ -3744,10 +3788,12 @@
* for an element, or null if there is no transformation (in
* which case it is not combined)
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all values
+ *
+ * @since 1.8
*/
public <U> U reduceValues(long parallelismThreshold,
Function<? super V, ? extends U> transformer,
BiFunction<? super U, ? super U, ? extends U> reducer) {
if (transformer == null || reducer == null)
@@ -3768,10 +3814,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all values
+ *
+ * @since 1.8
*/
public double reduceValuesToDouble(long parallelismThreshold,
ToDoubleFunction<? super V> transformer,
double basis,
DoubleBinaryOperator reducer) {
@@ -3793,10 +3841,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all values
+ *
+ * @since 1.8
*/
public long reduceValuesToLong(long parallelismThreshold,
ToLongFunction<? super V> transformer,
long basis,
LongBinaryOperator reducer) {
@@ -3818,10 +3868,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all values
+ *
+ * @since 1.8
*/
public int reduceValuesToInt(long parallelismThreshold,
ToIntFunction<? super V> transformer,
int basis,
IntBinaryOperator reducer) {
@@ -3836,10 +3888,12 @@
* Performs the given action for each entry.
*
* @param parallelismThreshold the (estimated) number of elements
* needed for this operation to be executed in parallel
* @param action the action
+ *
+ * @since 1.8
*/
public void forEachEntry(long parallelismThreshold,
Consumer<? super Map.Entry<K,V>> action) {
if (action == null) throw new NullPointerException();
new ForEachEntryTask<K,V>(null, batchFor(parallelismThreshold), 0, 0, table,
@@ -3854,10 +3908,12 @@
* needed for this operation to be executed in parallel
* @param transformer a function returning the transformation
* for an element, or null if there is no transformation (in
* which case the action is not applied)
* @param action the action
+ *
+ * @since 1.8
*/
public <U> void forEachEntry(long parallelismThreshold,
Function<Map.Entry<K,V>, ? extends U> transformer,
Consumer<? super U> action) {
if (transformer == null || action == null)
@@ -3878,10 +3934,12 @@
* needed for this operation to be executed in parallel
* @param searchFunction a function returning a non-null
* result on success, else null
* @return a non-null result from applying the given search
* function on each entry, or null if none
+ *
+ * @since 1.8
*/
public <U> U searchEntries(long parallelismThreshold,
Function<Map.Entry<K,V>, ? extends U> searchFunction) {
if (searchFunction == null) throw new NullPointerException();
return new SearchEntriesTask<K,V,U>
@@ -3895,10 +3953,12 @@
*
* @param parallelismThreshold the (estimated) number of elements
* needed for this operation to be executed in parallel
* @param reducer a commutative associative combining function
* @return the result of accumulating all entries
+ *
+ * @since 1.8
*/
public Map.Entry<K,V> reduceEntries(long parallelismThreshold,
BiFunction<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) {
if (reducer == null) throw new NullPointerException();
return new ReduceEntriesTask<K,V>
@@ -3917,10 +3977,12 @@
* for an element, or null if there is no transformation (in
* which case it is not combined)
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all entries
+ *
+ * @since 1.8
*/
public <U> U reduceEntries(long parallelismThreshold,
Function<Map.Entry<K,V>, ? extends U> transformer,
BiFunction<? super U, ? super U, ? extends U> reducer) {
if (transformer == null || reducer == null)
@@ -3941,10 +4003,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all entries
+ *
+ * @since 1.8
*/
public double reduceEntriesToDouble(long parallelismThreshold,
ToDoubleFunction<Map.Entry<K,V>> transformer,
double basis,
DoubleBinaryOperator reducer) {
@@ -3966,10 +4030,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all entries
+ *
+ * @since 1.8
*/
public long reduceEntriesToLong(long parallelismThreshold,
ToLongFunction<Map.Entry<K,V>> transformer,
long basis,
LongBinaryOperator reducer) {
@@ -3991,10 +4057,12 @@
* for an element
* @param basis the identity (initial default value) for the reduction
* @param reducer a commutative associative combining function
* @return the result of accumulating the given transformation
* of all entries
+ *
+ * @since 1.8
*/
public int reduceEntriesToInt(long parallelismThreshold,
ToIntFunction<Map.Entry<K,V>> transformer,
int basis,
IntBinaryOperator reducer) {
@@ -4166,10 +4234,12 @@
* common value. This class cannot be directly instantiated.
* See {@link #keySet() keySet()},
* {@link #keySet(Object) keySet(V)},
* {@link #newKeySet() newKeySet()},
* {@link #newKeySet(int) newKeySet(int)}.
+ *
+ * @since 1.8
*/
public static class KeySetView<K,V> extends CollectionView<K,V,K>
implements Set<K>, java.io.Serializable {
private static final long serialVersionUID = 7249069246763182397L;
private final V value;