示例#1
0
        public int BinarySearch(T[] array, int index, int length, T value, IComparer <T> comparer)
        {
            Debug.Assert(array != null, "Check the arguments in the caller!");
            Debug.Assert(index >= 0 && length >= 0 && (array.Length - index >= length), "Check the arguments in the caller!");

            try
            {
                if (comparer == null || comparer == Comparer <T> .Default)
                {
                    return(BinarySearch(array, index, length, value));
                }
                else
                {
                    return(ArraySortHelper <T> .InternalBinarySearch(array, index, length, value, comparer));
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);
            }
        }
示例#2
0
 public int BinarySearch(T[] array, int index, int length, T value, IComparer <T> comparer)
 {
     try
     {
         if (comparer == null || comparer == Comparer <T> .Default)
         {
             return(GenericArraySortHelper <T> .BinarySearch(array, index, length, value));
         }
         return(ArraySortHelper <T> .InternalBinarySearch(array, index, length, value, comparer));
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), ex);
     }
 }
示例#3
0
 public int BinarySearch(T[] array, int index, int length, T value, IComparer <T> comparer)
 {
     try
     {
         if (comparer == null || comparer == Comparer <T> .Default)
         {
             return(BinarySearch(array, index, length, value));
         }
         else
         {
             return(ArraySortHelper <T> .InternalBinarySearch(array, index, length, value, comparer));
         }
     }
     catch (Exception e)
     {
         throw new InvalidOperationException("InvalidOperation_IComparerFailed");
     }
 }
示例#4
0
        // Token: 0x06003A1C RID: 14876 RVA: 0x000DC234 File Offset: 0x000DA434
        public int BinarySearch(T[] array, int index, int length, T value, IComparer <T> comparer)
        {
            int result;

            try
            {
                if (comparer == null)
                {
                    comparer = Comparer <T> .Default;
                }
                result = ArraySortHelper <T> .InternalBinarySearch(array, index, length, value, comparer);
            }
            catch (Exception innerException)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), innerException);
            }
            return(result);
        }
示例#5
0
        public int BinarySearch(T[] array, int index, int length, T value, IComparer <T> comparer)
        {
            Contract.Assert(array != null, "Check the arguments in the caller!");
            Contract.Assert(index >= 0 && length >= 0 && (array.Length - index >= length), "Check the arguments in the caller!");

            try
            {
                if (comparer == null || comparer == Comparer <T> .Default)
                {
                    return(BinarySearch(array, index, length, value));
                }
                else
                {
                    return(ArraySortHelper <T> .InternalBinarySearch(array, index, length, value, comparer));
                }
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), e);
            }
        }