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

◆ PickPivotAndPartition()

int System.Array.SorterObjectArray.PickPivotAndPartition ( int lo,
int hi )
inlineprivate

Definition at line 126 of file Array.cs.

127 {
128 int num = lo + (hi - lo) / 2;
129 SwapIfGreater(lo, num);
130 SwapIfGreater(lo, hi);
131 SwapIfGreater(num, hi);
132 object obj = keys[num];
133 Swap(num, hi - 1);
134 int num2 = lo;
135 int num3 = hi - 1;
136 while (num2 < num3)
137 {
138 while (comparer.Compare(keys[++num2], obj) < 0)
139 {
140 }
141 while (comparer.Compare(obj, keys[--num3]) < 0)
142 {
143 }
144 if (num2 >= num3)
145 {
146 break;
147 }
148 Swap(num2, num3);
149 }
150 if (num2 != hi - 1)
151 {
152 Swap(num2, hi - 1);
153 }
154 return num2;
155 }
void Swap(int i, int j)
Definition Array.cs:53
void SwapIfGreater(int a, int b)
Definition Array.cs:37
readonly object[] keys
Definition Array.cs:24
readonly IComparer comparer
Definition Array.cs:28

References System.Collections.Generic.IComparer< in T >.Compare(), System.Array.SorterObjectArray.comparer, System.Array.SorterObjectArray.keys, System.obj, System.Array.SorterObjectArray.Swap(), and System.Array.SorterObjectArray.SwapIfGreater().

Referenced by System.Array.SorterObjectArray.IntroSort().