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

◆ IntroSort() [2/2]

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

Definition at line 309 of file ArraySortHelper.cs.

310 {
311 int num = keys.Length;
312 while (num > 1)
313 {
314 if (num <= 16)
315 {
316 switch (num)
317 {
318 case 2:
320 break;
321 case 3:
325 break;
326 default:
327 InsertionSort(keys.Slice(0, num), values.Slice(0, num), comparer);
328 break;
329 }
330 break;
331 }
332 if (depthLimit == 0)
333 {
334 HeapSort(keys.Slice(0, num), values.Slice(0, num), comparer);
335 break;
336 }
337 depthLimit--;
338 int num2 = PickPivotAndPartition(keys.Slice(0, num), values.Slice(0, num), comparer);
339 Span<TKey> span = keys;
340 Span<TKey> keys2 = span[(num2 + 1)..num];
341 Span<TValue> span2 = values;
342 IntroSort(keys2, span2[(num2 + 1)..num], depthLimit, comparer);
343 num = num2;
344 }
345 }
static void IntroSort(Span< T > keys, int depthLimit, Comparison< T > comparer)
static void SwapIfGreaterWithValues(Span< TKey > keys, Span< TValue > values, IComparer< TKey > comparer, int i, int j)
static void HeapSort(Span< T > keys, Comparison< T > comparer)
static int PickPivotAndPartition(Span< T > keys, Comparison< T > comparer)
static void InsertionSort(Span< T > keys, Comparison< T > comparer)

References System.comparer, System.Collections.Generic.ArraySortHelper< TKey, TValue >.HeapSort(), System.Collections.Generic.ArraySortHelper< TKey, TValue >.InsertionSort(), System.Collections.Generic.ArraySortHelper< TKey, TValue >.IntroSort(), System.keys, System.Collections.Generic.ArraySortHelper< TKey, TValue >.PickPivotAndPartition(), System.Collections.Generic.ArraySortHelper< TKey, TValue >.SwapIfGreaterWithValues(), and System.values.