/** * Sorts the given random access {@link List} in natural order. * The list must implement {@link RandomAccess}. This method uses the Tim sort * algorithm, but falls back to binary sort for small lists. * @throws IllegalArgumentException if list is e.g. a linked list without random access. */ public static <T extends Comparable<? super T>> void timSort(List<T> list) { final int size = list.size(); if (size <= 1) return; timSort(list, ArrayUtil.<T>naturalComparator()); }
/** * Sorts the given array slice in natural order. This method uses the Tim sort * algorithm, but falls back to binary sort for small arrays. * @param fromIndex start index (inclusive) * @param toIndex end index (exclusive) */ public static <T extends Comparable<? super T>> void timSort(T[] a, int fromIndex, int toIndex) { if (toIndex-fromIndex <= 1) return; timSort(a, fromIndex, toIndex, ArrayUtil.<T>naturalComparator()); }
/** * Sorts the given random access {@link List} in natural order. * The list must implement {@link RandomAccess}. This method uses the intro sort * algorithm, but falls back to insertion sort for small lists. * @throws IllegalArgumentException if list is e.g. a linked list without random access. */ public static <T extends Comparable<? super T>> void introSort(List<T> list) { final int size = list.size(); if (size <= 1) return; introSort(list, ArrayUtil.<T>naturalComparator()); }
/** * Sorts the given array slice in natural order. This method uses the Tim sort * algorithm, but falls back to binary sort for small arrays. * @param fromIndex start index (inclusive) * @param toIndex end index (exclusive) */ public static <T extends Comparable<? super T>> void timSort(T[] a, int fromIndex, int toIndex) { if (toIndex-fromIndex <= 1) return; timSort(a, fromIndex, toIndex, ArrayUtil.<T>naturalComparator()); }
/** * Sorts the given random access {@link List} in natural order. * The list must implement {@link RandomAccess}. This method uses the intro sort * algorithm, but falls back to insertion sort for small lists. * @throws IllegalArgumentException if list is e.g. a linked list without random access. */ public static <T extends Comparable<? super T>> void introSort(List<T> list) { final int size = list.size(); if (size <= 1) return; introSort(list, ArrayUtil.<T>naturalComparator()); }
/** * Sorts the given array slice in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. * @param fromIndex start index (inclusive) * @param toIndex end index (exclusive) */ public static <T extends Comparable<? super T>> void introSort(T[] a, int fromIndex, int toIndex) { if (toIndex-fromIndex <= 1) return; introSort(a, fromIndex, toIndex, ArrayUtil.<T>naturalComparator()); }
/** * Sorts the given array slice in natural order. This method uses the intro sort * algorithm, but falls back to insertion sort for small arrays. * @param fromIndex start index (inclusive) * @param toIndex end index (exclusive) */ public static <T extends Comparable<? super T>> void introSort(T[] a, int fromIndex, int toIndex) { if (toIndex-fromIndex <= 1) return; introSort(a, fromIndex, toIndex, ArrayUtil.<T>naturalComparator()); }
/** * Sorts the given random access {@link List} in natural order. * The list must implement {@link RandomAccess}. This method uses the Tim sort * algorithm, but falls back to binary sort for small lists. * @throws IllegalArgumentException if list is e.g. a linked list without random access. */ public static <T extends Comparable<? super T>> void timSort(List<T> list) { final int size = list.size(); if (size <= 1) return; timSort(list, ArrayUtil.<T>naturalComparator()); }