Language

Properties.ComputeIfAbsent(Object, IFunction) Method

Definition

Computes and stores a value only when this object has no entry for the key.

[Android.Runtime.Register("computeIfAbsent", "(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;", "GetComputeIfAbsent_Ljava_lang_Object_Ljava_util_function_Function_Handler", ApiSince=35)]
public virtual Java.Lang.Object? ComputeIfAbsent(Java.Lang.Object? key, Java.Util.Functions.IFunction? mappingFunction);
[<Android.Runtime.Register("computeIfAbsent", "(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;", "GetComputeIfAbsent_Ljava_lang_Object_Ljava_util_function_Function_Handler", ApiSince=35)>]
abstract member ComputeIfAbsent : Java.Lang.Object * Java.Util.Functions.IFunction -> Java.Lang.Object
override this.ComputeIfAbsent : Java.Lang.Object * Java.Util.Functions.IFunction -> Java.Lang.Object

Parameters

key
Object

The non-null key to look up or add.

mappingFunction
IFunction

The non-null function that computes a value from the absent key.

Returns

The existing or computed value, or null if the function produces no value.

Attributes

Remarks

A null function result is not stored. The function must not modify this map during computation. Entries in the default property list do not prevent this computation.

Applies to