Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AddOrUpdate< TKey, TValue >() [2/2]

static TValue System.Collections.Immutable.ImmutableInterlocked.AddOrUpdate< TKey, TValue > ( ref ImmutableDictionary< TKey, TValue > location,
TKey key,
TValue addValue,
Func< TKey, TValue, TValue > updateValueFactory )
inlinestatic
Type Constraints
TKey :notnull 

Definition at line 175 of file ImmutableInterlocked.cs.

175 : notnull
176 {
177 Requires.NotNull(updateValueFactory, "updateValueFactory");
179 TValue val;
180 bool flag;
181 do
182 {
183 Requires.NotNull(immutableDictionary, "location");
184 val = (TValue)((!immutableDictionary.TryGetValue(key, out var value)) ? ((object)addValue) : ((object)updateValueFactory(key, value)));
187 {
188 return value;
189 }
193 }
194 while (!flag);
195 return val;
196 }
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
static int CompareExchange(ref int location1, int value, int comparand)
static bool Read(ref bool location)
Definition Volatile.cs:67

References System.Threading.Interlocked.CompareExchange(), System.key, System.Threading.Volatile.Read(), System.Collections.Generic.Dictionary< TKey, TValue >.TryGetValue(), and System.value.