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

◆ LeafToRootRefill()

ImmutableSortedSet< T > System.Collections.Immutable.ImmutableSortedSet< T >.LeafToRootRefill ( IEnumerable< T > addedItems)
inlineprivate

Definition at line 1471 of file ImmutableSortedSet.cs.

1472 {
1473 Requires.NotNull(addedItems, "addedItems");
1474 List<T> list;
1475 if (IsEmpty)
1476 {
1477 if (addedItems.TryGetCount(out var count) && count == 0)
1478 {
1479 return this;
1480 }
1481 list = new List<T>(addedItems);
1482 if (list.Count == 0)
1483 {
1484 return this;
1485 }
1486 }
1487 else
1488 {
1489 list = new List<T>(this);
1490 list.AddRange(addedItems);
1491 }
1492 IComparer<T> keyComparer = KeyComparer;
1493 list.Sort(keyComparer);
1494 int num = 1;
1495 for (int i = 1; i < list.Count; i++)
1496 {
1497 if (keyComparer.Compare(list[i], list[i - 1]) != 0)
1498 {
1499 list[num++] = list[i];
1500 }
1501 }
1502 list.RemoveRange(num, list.Count - num);
1503 Node root = Node.NodeTreeFromList(list.AsOrderedCollection(), 0, list.Count);
1504 return Wrap(root);
1505 }
static ImmutableSortedSet< T > Wrap(Node root, IComparer< T > comparer)

References System.count, System.Collections.Immutable.ImmutableSortedSet< T >.IsEmpty, System.Collections.Immutable.ImmutableSortedSet< T >.KeyComparer, System.list, System.Collections.Immutable.ImmutableSortedSet< T >.Node.NodeTreeFromList(), and System.Collections.Immutable.ImmutableSortedSet< T >.Wrap().

Referenced by System.Collections.Immutable.ImmutableSortedSet< T >.Union().