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

◆ Sort() [4/4]

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

Implements System.Collections.Generic.IArraySortHelper< TKey, TValue >.

Definition at line 494 of file GenericArraySortHelper.cs.

495 {
496 try
497 {
498 if (comparer == null || comparer == Comparer<TKey>.Default)
499 {
500 if (keys.Length <= 1)
501 {
502 return;
503 }
504 if (typeof(TKey) == typeof(double) || typeof(TKey) == typeof(float) || typeof(TKey) == typeof(Half))
505 {
506 int num = SortUtils.MoveNansToFront(keys, values);
507 if (num == keys.Length)
508 {
509 return;
510 }
511 keys = keys.Slice(num);
512 values = values.Slice(num);
513 }
514 IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1));
515 }
516 else
517 {
518 ArraySortHelper<TKey, TValue>.IntrospectiveSort(keys, values, comparer);
519 }
520 }
521 catch (IndexOutOfRangeException)
522 {
523 ThrowHelper.ThrowArgumentException_BadComparer(comparer);
524 }
525 catch (Exception e)
526 {
527 ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
528 }
529 }
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(), System.ThrowHelper.ThrowInvalidOperationException(), and System.values.