Прочетете на английски Редактиране

Споделяне чрез


ImmutableInterlocked.GetOrAdd Method

Definition

Overloads

GetOrAdd<TKey,TValue,TArg>(ImmutableDictionary<TKey,TValue>, TKey, Func<TKey,TArg,TValue>, TArg)

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

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

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

GetOrAdd<TKey,TValue>(ImmutableDictionary<TKey,TValue>, TKey, TValue)

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

GetOrAdd<TKey,TValue,TArg>(ImmutableDictionary<TKey,TValue>, TKey, Func<TKey,TArg,TValue>, TArg)

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

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

C#
public static TValue GetOrAdd<TKey,TValue,TArg>(ref System.Collections.Immutable.ImmutableDictionary<TKey,TValue> location, TKey key, Func<TKey,TArg,TValue> valueFactory, TArg factoryArgument);

Type Parameters

TKey

The type of the keys contained in the collection.

TValue

The type of the values contained in the collection.

TArg

The type of the argument supplied to the value factory.

Parameters

location
ImmutableDictionary<TKey,TValue>

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

key
TKey

The key for the value to retrieve or add.

valueFactory
Func<TKey,TArg,TValue>

The function to execute to obtain the value to insert into the dictionary if the key is not found.

factoryArgument
TArg

The argument to pass to the value factory.

Returns

TValue

The value at the specified key or valueFactory if the key was not present.

Applies to

.NET 10 и други версии
Продукт Версии
.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, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)
UWP 10.0

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

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

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

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

Type Parameters

TKey

The type of the keys contained in the collection.

TValue

The type of the values contained in the collection.

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 retrieve or add.

valueFactory
Func<TKey,TValue>

The function to execute to obtain the value to insert into the dictionary if the key is not found. This delegate will not be invoked more than once.

Returns

TValue

The value at the specified key or valueFactory if the key was not present.

Applies to

.NET 10 и други версии
Продукт Версии
.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, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)
UWP 10.0

GetOrAdd<TKey,TValue>(ImmutableDictionary<TKey,TValue>, TKey, TValue)

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

Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary.

C#
public static TValue GetOrAdd<TKey,TValue>(ref System.Collections.Immutable.ImmutableDictionary<TKey,TValue> location, TKey key, TValue value);

Type Parameters

TKey

The type of the keys contained in the collection.

TValue

The type of the values contained in the collection.

Parameters

location
ImmutableDictionary<TKey,TValue>

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

key
TKey

The key for the value to get or add.

value
TValue

The value to add to the dictionary if the key isn't found.

Returns

TValue

The value at the specified key, if present.

Applies to

.NET 10 и други версии
Продукт Версии
.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, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)
UWP 10.0