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

◆ PickPivotAndPartition() [2/2]

static int System.Collections.Generic.GenericArraySortHelper< TKey, TValue >.PickPivotAndPartition ( Span< TKey > keys,
Span< TValue > values )
inlinestaticprivate

Definition at line 594 of file GenericArraySortHelper.cs.

595 {
596 int num = keys.Length - 1;
597 int num2 = num >> 1;
601 TKey left = keys[num2];
602 Swap(keys, values, num2, num - 1);
603 int num3 = 0;
604 int num4 = num - 1;
605 while (num3 < num4)
606 {
607 if (left == null)
608 {
609 while (num3 < num - 1 && keys[++num3] == null)
610 {
611 }
612 while (num4 > 0 && keys[--num4] != null)
613 {
614 }
615 }
616 else
617 {
618 while (GreaterThan(ref left, ref keys[++num3]))
619 {
620 }
621 while (LessThan(ref left, ref keys[--num4]))
622 {
623 }
624 }
625 if (num3 >= num4)
626 {
627 break;
628 }
629 Swap(keys, values, num3, num4);
630 }
631 if (num3 != num - 1)
632 {
633 Swap(keys, values, num3, num - 1);
634 }
635 return num3;
636 }
static void SwapIfGreaterWithValues(Span< TKey > keys, Span< TValue > values, int i, int j)

References System.Collections.Generic.GenericArraySortHelper< TKey, TValue >.GreaterThan(), System.keys, System.Collections.Generic.GenericArraySortHelper< TKey, TValue >.LessThan(), System.Collections.Generic.GenericArraySortHelper< TKey, TValue >.Swap(), System.Collections.Generic.GenericArraySortHelper< TKey, TValue >.SwapIfGreaterWithValues(), and System.values.