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

◆ SetOrAdd()

SortedInt32KeyNode< TValue > System.Collections.Immutable.SortedInt32KeyNode< TValue >.SetOrAdd ( int key,
TValue value,
IEqualityComparer< TValue > valueComparer,
bool overwriteExistingValue,
out bool replacedExistingValue,
out bool mutated )
inlineprivate

Definition at line 332 of file SortedInt32KeyNode.cs.

333 {
334 replacedExistingValue = false;
335 if (IsEmpty)
336 {
337 mutated = true;
338 return new SortedInt32KeyNode<TValue>(key, value, this, this);
339 }
341 if (key > _key)
342 {
344 if (mutated)
345 {
346 sortedInt32KeyNode = Mutate(null, right);
347 }
348 }
349 else if (key < _key)
350 {
352 if (mutated)
353 {
355 }
356 }
357 else
358 {
359 if (valueComparer.Equals(_value, value))
360 {
361 mutated = false;
362 return this;
363 }
365 {
367 }
368 mutated = true;
371 }
372 if (!mutated)
373 {
374 return sortedInt32KeyNode;
375 }
377 }
SortedInt32KeyNode< TValue > Mutate(SortedInt32KeyNode< TValue > left=null, SortedInt32KeyNode< TValue > right=null)
static SortedInt32KeyNode< TValue > MakeBalanced(SortedInt32KeyNode< TValue > tree)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string DuplicateKey
Definition SR.cs:28
Definition SR.cs:7

References System.Collections.Immutable.SortedInt32KeyNode< TValue >._key, System.Collections.Immutable.SortedInt32KeyNode< TValue >._left, System.Collections.Immutable.SortedInt32KeyNode< TValue >._right, System.Collections.Immutable.SortedInt32KeyNode< TValue >._value, System.SR.DuplicateKey, System.SR.Format(), System.Collections.Immutable.SortedInt32KeyNode< TValue >.IsEmpty, System.key, System.Collections.Immutable.SortedInt32KeyNode< TValue >.MakeBalanced(), System.Collections.Immutable.SortedInt32KeyNode< TValue >.Mutate(), and System.value.

Referenced by System.Collections.Immutable.SortedInt32KeyNode< TValue >.SetItem().