- All Implemented Interfaces:
IntegerSortAlgorithm,SortAlgorithm<Number>
Although a very different implementation, this topic is discussed at http://erik.gorset.no/2011/04/radix-sort-is-faster-than-quicksort.html with source provided at https://github.com/gorset/radix/blob/master/Radix.java.
TODO: For concurrent implementation: Might get better performance (due to cache locality of reference) by flattening the two-dimensional fixed dimensions of the arrays into a single dimension.
TODO: For concurrent implementation: Might also consider changing the row/column order of the multi-dimensional arrays to help cache interaction. Might get better throughput when hit the cache wall where performance drops considerably.
- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionprotected static intget(int[] array, int i, SortStatistics stats) protected static intget(IntList list, int i, SortStatistics stats) protected static <T> Tget(List<T> list, int i, SortStatistics stats) protected static <T> Tget(T[] array, int i, SortStatistics stats) static IntegerRadixSortGets the default IntegerRadixSort using the default executor service.static IntegerRadixSortgetInstance(ExecutorService executor) Gets a IntegerRadixSort that uses the provided ExecutorService.static IntegerRadixSortGets a single-threaded instance of IntegerRadixSort, that will not ever sort concurrently.booleanisStable()Checks if this is a stable sort.protected static voidset(int[] array, int i, int value, SortStatistics stats) protected static voidset(IntList list, int i, int value, SortStatistics stats) protected static <T> voidset(List<T> list, int i, T o, SortStatistics stats) protected static <T> voidset(T[] array, int i, T o, SortStatistics stats) voidsort(int[] array) voidsort(int[] array, SortStatistics stats) voidvoidsort(IntList list, SortStatistics stats) <N extends Number>
voidsort(List<N> list, SortStatistics stats) <T extends E>
void<N extends Number>
voidsort(N[] array, SortStatistics stats) <T extends E>
voidsort(T[] array) protected static voidswap(int[] array, int i, int j, SortStatistics stats) protected static voidswap(IntList list, int i, int j, SortStatistics stats) protected static <T> voidswap(List<T> list, int i, int j, SortStatistics stats) protected static <T> voidswap(T[] array, int i, int j, SortStatistics stats) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.aoapps.hodgepodge.sort.SortAlgorithm
sort, sort
-
Method Details
-
getInstance
Gets the default IntegerRadixSort using the default executor service. This will use concurrency where appropriate (long lists/arrays on multi-core systems). -
getSingleThreadedInstance
Gets a single-threaded instance of IntegerRadixSort, that will not ever sort concurrently. As the determination of when to use concurrency should avoid any potential downfalls, it is recommended to use the default instance fromgetInstancefor most scenarios.- See Also:
-
getInstance
Gets a IntegerRadixSort that uses the provided ExecutorService. If the executor service isnull, concurrency is disabled. -
isStable
public boolean isStable()Description copied from interface:SortAlgorithmChecks if this is a stable sort. A stable sort will keep elements with equal values in their same relative order. -
sort
- Specified by:
sortin interfaceSortAlgorithm<Number>
-
sort
- Specified by:
sortin interfaceSortAlgorithm<Number>
-
sort
- Specified by:
sortin interfaceIntegerSortAlgorithm
-
sort
- Specified by:
sortin interfaceIntegerSortAlgorithm
-
sort
- Specified by:
sortin interfaceIntegerSortAlgorithm
-
sort
public void sort(int[] array) - Specified by:
sortin interfaceIntegerSortAlgorithm
-
get
-
get
-
set
-
set
-
swap
-
swap
-
sort
- Specified by:
sortin interfaceSortAlgorithm<E>
-
sort
public <T extends E> void sort(T[] array) - Specified by:
sortin interfaceSortAlgorithm<E>
-
get
-
get
-
set
-
set
-
swap
-
swap
-
