ConcurrentHashMap.Merge(Object, Object, IBiFunction) Method

Definition

If the specified key is not already associated with a (non-null) value, associates it with the given value.

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

Parameters

key
Object

key with which the specified value is to be associated

value
Object

the value to use if absent

remappingFunction
IBiFunction

the function to recompute a value if present

Returns

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

Implements

Attributes

Remarks

If the specified key is not already associated with a (non-null) value, associates it with the given value. Otherwise, replaces the value with the results of the given remapping function, or removes if null. The entire method invocation is performed atomically. 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, and must not attempt to update any other mappings of this Map.

Java documentation for java.util.concurrent.ConcurrentHashMap.merge(K, V, java.util.function.BiFunction<? super V, ? 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