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

◆ Sort() [1/4]

void System.Collections.Generic.GenericArraySortHelper< TKey, TValue >.Sort ( Span< T > keys,
IComparer< T > comparer )
inline

Definition at line 10 of file GenericArraySortHelper.cs.

11 {
12 try
13 {
14 if (comparer == null || comparer == Comparer<T>.Default)
15 {
16 if (keys.Length <= 1)
17 {
18 return;
19 }
20 if (typeof(T) == typeof(double) || typeof(T) == typeof(float) || typeof(T) == typeof(Half))
21 {
22 int num = SortUtils.MoveNansToFront(keys, default(Span<byte>));
23 if (num == keys.Length)
24 {
25 return;
26 }
27 keys = keys.Slice(num);
28 }
29 IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1));
30 }
31 else
32 {
33 ArraySortHelper<T>.IntrospectiveSort(keys, comparer.Compare);
34 }
35 }
36 catch (IndexOutOfRangeException)
37 {
38 ThrowHelper.ThrowArgumentException_BadComparer(comparer);
39 }
40 catch (Exception e)
41 {
42 ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
43 }
44 }
static void IntroSort(Span< T > keys, int depthLimit)
static int Log2(uint value)

References System.comparer, System.Default, System.Collections.Generic.GenericArraySortHelper< TKey, TValue >.IntroSort(), System.keys, System.Numerics.BitOperations.Log2(), System.ThrowHelper.ThrowArgumentException_BadComparer(), and System.ThrowHelper.ThrowInvalidOperationException().