Example #1
0
 // Token: 0x06003A38 RID: 14904 RVA: 0x000DCD3C File Offset: 0x000DAF3C
 public void Sort(TKey[] keys, TValue[] values, int index, int length, IComparer <TKey> comparer)
 {
     try
     {
         if (comparer == null || comparer == Comparer <TKey> .Default)
         {
             comparer = Comparer <TKey> .Default;
         }
         if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
         {
             ArraySortHelper <TKey, TValue> .IntrospectiveSort(keys, values, index, length, comparer);
         }
         else
         {
             ArraySortHelper <TKey, TValue> .DepthLimitedQuickSort(keys, values, index, length + index - 1, comparer, 32);
         }
     }
     catch (IndexOutOfRangeException)
     {
         IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer(comparer);
     }
     catch (Exception innerException)
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), innerException);
     }
 }
Example #2
0
        // Do not add a constructor to this class because ArraySortHelper<T>.CreateSortHelper will not execute it

        #region IArraySortHelper<T> Members

        public void Sort(T[] keys, int index, int length, IComparer <T> comparer)
        {
            Debug.Assert(keys != null, "Check the arguments in the caller!");
            Debug.Assert(index >= 0 && length >= 0 && (keys.Length - index >= length), "Check the arguments in the caller!");

            try
            {
                if (comparer == null || comparer == Comparer <T> .Default)
                {
                    IntrospectiveSort(keys, index, length);
                }
                else
                {
                    ArraySortHelper <T> .IntrospectiveSort(keys, index, length, comparer.Compare);
                }
            }
            catch (IndexOutOfRangeException)
            {
                IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer(comparer);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);
            }
        }
Example #3
0
 public void Sort(T[] keys, int index, int length, IComparer <T> comparer)
 {
     try
     {
         if (comparer == null || comparer == Comparer <T> .Default)
         {
             if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
             {
                 GenericArraySortHelper <T> .IntrospectiveSort(keys, index, length);
             }
             else
             {
                 GenericArraySortHelper <T> .DepthLimitedQuickSort(keys, index, length + index - 1, 32);
             }
         }
         else if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
         {
             ArraySortHelper <T> .IntrospectiveSort(keys, index, length, comparer);
         }
         else
         {
             ArraySortHelper <T> .DepthLimitedQuickSort(keys, index, length + index - 1, comparer, 32);
         }
     }
     catch (IndexOutOfRangeException ex)
     {
         IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer((object)comparer);
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), ex);
     }
 }