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

◆ PickPivotAndPartition()

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

Definition at line 331 of file Array.cs.

332 {
333 int num = lo + (hi - lo) / 2;
334 SwapIfGreater(lo, num);
335 SwapIfGreater(lo, hi);
336 SwapIfGreater(num, hi);
337 object value = keys.GetValue(num);
338 Swap(num, hi - 1);
339 int num2 = lo;
340 int num3 = hi - 1;
341 while (num2 < num3)
342 {
343 while (comparer.Compare(keys.GetValue(++num2), value) < 0)
344 {
345 }
346 while (comparer.Compare(value, keys.GetValue(--num3)) < 0)
347 {
348 }
349 if (num2 >= num3)
350 {
351 break;
352 }
353 Swap(num2, num3);
354 }
355 if (num2 != hi - 1)
356 {
357 Swap(num2, hi - 1);
358 }
359 return num2;
360 }
object? GetValue(params int[] indices)
Definition Array.cs:980
void Swap(int i, int j)
Definition Array.cs:258
void SwapIfGreater(int a, int b)
Definition Array.cs:242
readonly IComparer comparer
Definition Array.cs:233

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

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