public static void Sort <T>( SegmentedArray <T> array, int index, int length, IComparer <T>?comparer ) { if (index < 0) { ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); } if (length < 0) { ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); } if (array.Length - index < length) { ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } if (length > 1) { var segment = new SegmentedArraySegment <T>(array, index, length); SegmentedArraySortHelper <T> .Sort(segment, comparer); } }
public static void Sort <T>(SegmentedArray <T> array) { if (array.Length > 1) { var segment = new SegmentedArraySegment <T>(array, 0, array.Length); SegmentedArraySortHelper <T> .Sort(segment, (IComparer <T>?) null); } }
public static int BinarySearch<T>(SegmentedArray<T> array, int index, int length, T value, IComparer<T>? comparer) { if (index < 0) ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); if (length < 0) ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); if (array.Length - index < length) ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); return SegmentedArraySortHelper<T>.BinarySearch(array, index, length, value, comparer); }
public static void Sort <T>(SegmentedArray <T> array, Comparison <T> comparison) { if (comparison is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.comparison); } if (array.Length > 1) { var segment = new SegmentedArraySegment <T>(array, 0, array.Length); SegmentedArraySortHelper <T> .Sort(segment, comparison); } }