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

◆ PickPivotAndPartition() [2/2]

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

Definition at line 347 of file ArraySortHelper.cs.

348 {
349 int num = keys.Length - 1;
350 int num2 = num >> 1;
354 TKey val = keys[num2];
355 Swap(keys, values, num2, num - 1);
356 int num3 = 0;
357 int num4 = num - 1;
358 while (num3 < num4)
359 {
360 while (comparer.Compare(keys[++num3], val) < 0)
361 {
362 }
363 while (comparer.Compare(val, keys[--num4]) < 0)
364 {
365 }
366 if (num3 >= num4)
367 {
368 break;
369 }
370 Swap(keys, values, num3, num4);
371 }
372 if (num3 != num - 1)
373 {
374 Swap(keys, values, num3, num - 1);
375 }
376 return num3;
377 }
static void SwapIfGreaterWithValues(Span< TKey > keys, Span< TValue > values, IComparer< TKey > comparer, int i, int j)
static void Swap(Span< T > a, int i, int j)

References System.comparer, System.keys, System.Collections.Generic.ArraySortHelper< TKey, TValue >.Swap(), System.Collections.Generic.ArraySortHelper< TKey, TValue >.SwapIfGreaterWithValues(), and System.values.