java.lang.Object
com.aoapps.hodgepodge.sort.AutoSort
- All Implemented Interfaces:
ComparisonSortAlgorithm<Object>
,SortAlgorithm<Object>
Attempts to automatically select the best sort algorithm based on information
available in the list. It takes into account list length and list type.
- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionprotected static <T> int
compare
(List<T> list, int i, int j, Comparator<? super T> comparator, SortStatistics stats) protected static <T> int
compare
(T[] array, int i, int j, Comparator<? super T> comparator, SortStatistics stats) protected static <T> int
compare
(T o1, T o2, Comparator<? super T> comparator, SortStatistics stats) protected static <T> T
get
(List<T> list, int i, SortStatistics stats) protected static <T> T
get
(T[] array, int i, SortStatistics stats) static AutoSort
static <T> ComparisonSortAlgorithm
<? super T> getRecommendedSortAlgorithm
(List<T> list) static <T> ComparisonSortAlgorithm
<? super T> getRecommendedSortAlgorithm
(T[] array) boolean
isStable()
Checks if this is a stable sort.protected static <T> void
set
(List<T> list, int i, T o, SortStatistics stats) protected static <T> void
set
(T[] array, int i, T o, SortStatistics stats) <T> void
<T> void
sort
(List<T> list, SortStatistics stats) <T> void
sort
(List<T> list, Comparator<? super T> comparator) <T> void
sort
(List<T> list, Comparator<? super T> comparator, SortStatistics stats) <T> void
sort
(T[] array) <T> void
sort
(T[] array, SortStatistics stats) <T> void
sort
(T[] array, Comparator<? super T> comparator) <T> void
sort
(T[] array, Comparator<? super T> comparator, SortStatistics stats) protected static <T> void
swap
(List<T> list, int i, int j, SortStatistics stats) protected static <T> void
swap
(T[] array, int i, int j, SortStatistics stats)
-
Method Details
-
getInstance
-
isStable
public boolean isStable()Description copied from interface:SortAlgorithm
Checks if this is a stable sort. A stable sort will keep elements with equal values in their same relative order. -
sort
- Specified by:
sort
in interfaceSortAlgorithm<Object>
-
sort
public <T> void sort(T[] array) - Specified by:
sort
in interfaceSortAlgorithm<Object>
-
sort
- Specified by:
sort
in interfaceSortAlgorithm<Object>
-
sort
- Specified by:
sort
in interfaceSortAlgorithm<Object>
-
sort
- Specified by:
sort
in interfaceComparisonSortAlgorithm<Object>
-
sort
- Specified by:
sort
in interfaceComparisonSortAlgorithm<Object>
-
sort
- Specified by:
sort
in interfaceComparisonSortAlgorithm<Object>
-
sort
- Specified by:
sort
in interfaceComparisonSortAlgorithm<Object>
-
getRecommendedSortAlgorithm
-
getRecommendedSortAlgorithm
-
compare
protected static <T> int compare(List<T> list, int i, int j, Comparator<? super T> comparator, SortStatistics stats) -
compare
protected static <T> int compare(T[] array, int i, int j, Comparator<? super T> comparator, SortStatistics stats) -
compare
protected static <T> int compare(T o1, T o2, Comparator<? super T> comparator, SortStatistics stats) -
get
-
get
-
set
-
set
-
swap
-
swap
-