ImmutableInterlocked.GetOrAdd 方法

定義

多載

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

從該字典取得指定索引鍵的值,或若找不到該索引鍵,則將新值加入字典。

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

從該字典取得指定索引鍵的值,或若找不到該索引鍵,則將新值加入字典。

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

從該字典取得指定索引鍵的值,或若找不到該索引鍵,則將新值加入字典。

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

從該字典取得指定索引鍵的值,或若找不到該索引鍵,則將新值加入字典。

public:
generic <typename TKey, typename TValue, typename TArg>
 static TValue GetOrAdd(System::Collections::Immutable::ImmutableDictionary<TKey, TValue> ^ % location, TKey key, Func<TKey, TArg, TValue> ^ valueFactory, TArg factoryArgument);
public static TValue GetOrAdd<TKey,TValue,TArg> (ref System.Collections.Immutable.ImmutableDictionary<TKey,TValue> location, TKey key, Func<TKey,TArg,TValue> valueFactory, TArg factoryArgument);
static member GetOrAdd : ImmutableDictionary * 'Key * Func<'Key, 'Arg, 'Value> * 'Arg -> 'Value
Public Shared Function GetOrAdd(Of TKey, TValue, TArg) (ByRef location As ImmutableDictionary(Of TKey, TValue), key As TKey, valueFactory As Func(Of TKey, TArg, TValue), factoryArgument As TArg) As TValue

類型參數

TKey

集合中所包含之索引鍵的類型。

TValue

集合中所包含之值的類型。

TArg

提供給實值處理站的引數型別。

參數

location
ImmutableDictionary<TKey,TValue>

如果字典中沒有指定的變數或欄位,該變數或欄位會更新。

key
TKey

要擷取或新增之值的索引鍵。

valueFactory
Func<TKey,TArg,TValue>

如果找不到索引鍵,則會執行該函式以取得要插入字典的值。

factoryArgument
TArg

要傳遞給值 Factory 的引數。

傳回

TValue

指定之索引鍵的值或 valueFactory (如果找不到索引鍵)。

適用於

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

從該字典取得指定索引鍵的值,或若找不到該索引鍵,則將新值加入字典。

public:
generic <typename TKey, typename TValue>
 static TValue GetOrAdd(System::Collections::Immutable::ImmutableDictionary<TKey, TValue> ^ % location, TKey key, Func<TKey, TValue> ^ valueFactory);
public static TValue GetOrAdd<TKey,TValue> (ref System.Collections.Immutable.ImmutableDictionary<TKey,TValue> location, TKey key, Func<TKey,TValue> valueFactory);
static member GetOrAdd : ImmutableDictionary * 'Key * Func<'Key, 'Value> -> 'Value
Public Shared Function GetOrAdd(Of TKey, TValue) (ByRef location As ImmutableDictionary(Of TKey, TValue), key As TKey, valueFactory As Func(Of TKey, TValue)) As TValue

類型參數

TKey

集合中所包含之索引鍵的類型。

TValue

集合中所包含之值的類型。

參數

location
ImmutableDictionary<TKey,TValue>

如果字典中沒有指定的變數或欄位,該變數或欄位會自動更新。

key
TKey

要擷取或新增之值的索引鍵。

valueFactory
Func<TKey,TValue>

如果找不到索引鍵,則會執行該函式以取得要插入字典的值。 不會叫用此委派一次以上。

傳回

TValue

指定之索引鍵的值或 valueFactory (如果找不到索引鍵)。

適用於

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

從該字典取得指定索引鍵的值,或若找不到該索引鍵,則將新值加入字典。

public:
generic <typename TKey, typename TValue>
 static TValue GetOrAdd(System::Collections::Immutable::ImmutableDictionary<TKey, TValue> ^ % location, TKey key, TValue value);
public static TValue GetOrAdd<TKey,TValue> (ref System.Collections.Immutable.ImmutableDictionary<TKey,TValue> location, TKey key, TValue value);
static member GetOrAdd : ImmutableDictionary * 'Key * 'Value -> 'Value
Public Shared Function GetOrAdd(Of TKey, TValue) (ByRef location As ImmutableDictionary(Of TKey, TValue), key As TKey, value As TValue) As TValue

類型參數

TKey

集合中所包含之索引鍵的類型。

TValue

集合中所包含之值的類型。

參數

location
ImmutableDictionary<TKey,TValue>

如果字典中沒有指定的索引鍵,該變數或欄位會自動更新。

key
TKey

要取得或加入之值的索引鍵。

value
TValue

如果找不到索引鍵,會將該值加入字典。

傳回

TValue

指定之索引鍵的值或 valueFactory (如果找不到索引鍵)。

適用於