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

◆ ConstructRootFromSortedArray()

static Node System.Collections.Generic.SortedSet< T >.ConstructRootFromSortedArray ( T[] arr,
int startIndex,
int endIndex,
Node redNode )
inlinestaticprivateinherited

Definition at line 1409 of file SortedSet.cs.

1410 {
1411 int num = endIndex - startIndex + 1;
1412 Node node;
1413 switch (num)
1414 {
1415 case 0:
1416 return null;
1417 case 1:
1418 node = new Node(arr[startIndex], NodeColor.Black);
1419 if (redNode != null)
1420 {
1422 }
1423 break;
1424 case 2:
1425 node = new Node(arr[startIndex], NodeColor.Black);
1426 node.Right = new Node(arr[endIndex], NodeColor.Black);
1427 node.Right.ColorRed();
1428 if (redNode != null)
1429 {
1431 }
1432 break;
1433 case 3:
1434 node = new Node(arr[startIndex + 1], NodeColor.Black);
1435 node.Left = new Node(arr[startIndex], NodeColor.Black);
1436 node.Right = new Node(arr[endIndex], NodeColor.Black);
1437 if (redNode != null)
1438 {
1440 }
1441 break;
1442 default:
1443 {
1444 int num2 = (startIndex + endIndex) / 2;
1445 node = new Node(arr[num2], NodeColor.Black);
1447 node.Right = ((num % 2 == 0) ? ConstructRootFromSortedArray(arr, num2 + 2, endIndex, new Node(arr[num2 + 1], NodeColor.Red)) : ConstructRootFromSortedArray(arr, num2 + 1, endIndex, null));
1448 break;
1449 }
1450 }
1451 return node;
1452 }
NodeColor
Definition RBTree.cs:10
static Node ConstructRootFromSortedArray(T[] arr, int startIndex, int endIndex, Node redNode)

References System.Collections.Generic.SortedSet< T >.ConstructRootFromSortedArray(), System.Runtime.Serialization.Dictionary, System.endIndex, and System.startIndex.

Referenced by System.Collections.Generic.SortedSet< T >.SortedSet(), System.Collections.Generic.SortedSet< T >.ConstructRootFromSortedArray(), System.Collections.Generic.SortedSet< T >.IntersectWith(), and System.Collections.Generic.SortedSet< T >.UnionWith().