Udostępnij za pośrednictwem


ConcurrentHashMap.ComputeIfPresent(Object, IBiFunction) Method

Definition

If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value.

[Android.Runtime.Register("computeIfPresent", "(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;", "GetComputeIfPresent_Ljava_lang_Object_Ljava_util_function_BiFunction_Handler", ApiSince=24)]
public virtual Java.Lang.Object? ComputeIfPresent (Java.Lang.Object key, Java.Util.Functions.IBiFunction remappingFunction);
[<Android.Runtime.Register("computeIfPresent", "(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;", "GetComputeIfPresent_Ljava_lang_Object_Ljava_util_function_BiFunction_Handler", ApiSince=24)>]
abstract member ComputeIfPresent : Java.Lang.Object * Java.Util.Functions.IBiFunction -> Java.Lang.Object
override this.ComputeIfPresent : Java.Lang.Object * Java.Util.Functions.IBiFunction -> Java.Lang.Object

Parameters

key
Object

key with which a value may be associated

remappingFunction
IBiFunction

the function to compute a value

Returns

the new value associated with the specified key, or null if none

Implements

Attributes

Remarks

If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value. The entire method invocation is performed atomically. The supplied function is invoked exactly once per invocation of this method if the key is present, else not at all. Some attempted update operations on this map by other threads may be blocked while computation is in progress, so the computation should be short and simple.

The remapping function must not modify this map during computation.

Java documentation for java.util.concurrent.ConcurrentHashMap.computeIfPresent(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to