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

◆ IntroSort() [1/2]

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

Definition at line 127 of file ArraySortHelper.cs.

128 {
129 int num = keys.Length;
130 while (num > 1)
131 {
132 if (num <= 16)
133 {
134 switch (num)
135 {
136 case 2:
138 break;
139 case 3:
143 break;
144 default:
145 InsertionSort(keys.Slice(0, num), comparer);
146 break;
147 }
148 break;
149 }
150 if (depthLimit == 0)
151 {
152 HeapSort(keys.Slice(0, num), comparer);
153 break;
154 }
155 depthLimit--;
156 int num2 = PickPivotAndPartition(keys.Slice(0, num), comparer);
157 Span<T> span = keys;
158 IntroSort(span[(num2 + 1)..num], depthLimit, comparer);
159 num = num2;
160 }
161 }
static void IntroSort(Span< T > keys, int depthLimit, Comparison< T > comparer)
static void HeapSort(Span< T > keys, Comparison< T > comparer)
static int PickPivotAndPartition(Span< T > keys, Comparison< T > comparer)
static void SwapIfGreater(Span< T > keys, Comparison< T > comparer, int i, int j)
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(), and System.Collections.Generic.ArraySortHelper< TKey, TValue >.SwapIfGreater().

Referenced by System.Collections.Generic.ArraySortHelper< TKey, TValue >.IntroSort(), System.Collections.Generic.ArraySortHelper< TKey, TValue >.IntroSort(), System.Collections.Generic.ArraySortHelper< TKey, TValue >.IntrospectiveSort(), and System.Collections.Generic.ArraySortHelper< TKey, TValue >.IntrospectiveSort().