示例#1
0
        internal static void Sort(Span <T> keys, Comparison <T> comparer)
        {
            Debug.Assert(comparer != null, "Check the arguments in the caller!");

            // Add a try block here to detect bogus comparisons
            try
            {
                IntrospectiveSort(keys, comparer);
            }
            catch (IndexOutOfRangeException)
            {
                ThrowHelper.ThrowArgumentException_BadComparer(comparer);
            }
            catch (Exception e)
            {
                ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
            }
        }
示例#2
0
 public void Sort(Span <T> keys, IComparer <T>?comparer)
 {
     // Add a try block here to detect IComparers (or their
     // underlying IComparables, etc) that are bogus.
     try
     {
         comparer ??= Comparer <T> .Default;
         IntrospectiveSort(keys, comparer.Compare);
     }
     catch (IndexOutOfRangeException)
     {
         ThrowHelper.ThrowArgumentException_BadComparer(comparer);
     }
     catch (Exception e)
     {
         ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_IComparerFailed, e);
     }
 }