ImmutableInterlocked.AddOrUpdate Method

Definition

Overloads

AddOrUpdate<TKey,TValue>(ImmutableDictionary<TKey,TValue>, TKey, Func<TKey,TValue>, Func<TKey,TValue,TValue>)

Obtains the value from a dictionary after having added it or updated an existing entry.

AddOrUpdate<TKey,TValue>(ImmutableDictionary<TKey,TValue>, TKey, TValue, Func<TKey,TValue,TValue>)

Obtains the value from a dictionary after having added it or updated an existing entry.

AddOrUpdate<TKey,TValue>(ImmutableDictionary<TKey,TValue>, TKey, Func<TKey,TValue>, Func<TKey,TValue,TValue>)

Source:
ImmutableInterlocked.cs
Source:
ImmutableInterlocked.cs
Source:
ImmutableInterlocked.cs
Source:
ImmutableInterlocked.cs

Obtains the value from a dictionary after having added it or updated an existing entry.

C#
public static TValue AddOrUpdate<TKey,TValue> (ref System.Collections.Immutable.ImmutableDictionary<TKey,TValue> location, TKey key, Func<TKey,TValue> addValueFactory, Func<TKey,TValue,TValue> updateValueFactory);

Type Parameters

TKey

The type of key stored by the dictionary.

TValue

The type of value stored by the dictionary.

Parameters

location
ImmutableDictionary<TKey,TValue>

The variable or field to atomically update if the specified is not in the dictionary.

key
TKey

The key for the value to add or update.

addValueFactory
Func<TKey,TValue>

The function that receives the key and returns a new value to add to the dictionary when no value previously exists.

updateValueFactory
Func<TKey,TValue,TValue>

The function that receives the key and prior value and returns the new value with which to update the dictionary.

Returns

TValue

The added or updated value.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)
UWP 10.0

AddOrUpdate<TKey,TValue>(ImmutableDictionary<TKey,TValue>, TKey, TValue, Func<TKey,TValue,TValue>)

Source:
ImmutableInterlocked.cs
Source:
ImmutableInterlocked.cs
Source:
ImmutableInterlocked.cs
Source:
ImmutableInterlocked.cs

Obtains the value from a dictionary after having added it or updated an existing entry.

C#
public static TValue AddOrUpdate<TKey,TValue> (ref System.Collections.Immutable.ImmutableDictionary<TKey,TValue> location, TKey key, TValue addValue, Func<TKey,TValue,TValue> updateValueFactory);

Type Parameters

TKey

The type of key stored by the dictionary.

TValue

The type of value stored by the dictionary.

Parameters

location
ImmutableDictionary<TKey,TValue>

The variable or field to atomically update if the specified is not in the dictionary.

key
TKey

The key for the value to add or update.

addValue
TValue

The value to use if no previous value exists.

updateValueFactory
Func<TKey,TValue,TValue>

The function that receives the key and prior value and returns the new value with which to update the dictionary.

Returns

TValue

The added or updated value.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)
UWP 10.0