Package org.lionsoul.jcseg.util
Class Sort
- java.lang.Object
-
- org.lionsoul.jcseg.util.Sort
-
public class Sort extends Object
All kind of Sort algorithm implemented method use the default compare method- Author:
- chenxin
-
-
Constructor Summary
Constructors Constructor Description Sort()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbucketSort(int[] arr, int m)bucket sort algorithmstatic voidbucketSort(Integer[] arr, int m)bucket sort algorithmstatic <T extends Comparable<? super T>>
voidinsertionSort(T[] arr)insert sort methodstatic <T extends Comparable<? super T>>
voidinsertionSort(T[] arr, int start, int end)method to sort an subarray from start to end with insertion sort algorithmstatic <T extends Comparable<? super T>>
voidmergeSort(T[] arr)merge sort algorithmstatic <T extends Comparable<? super T>>
voidquickSelect(T[] arr, int k)quick select algorithmstatic <T extends Comparable<? super T>>
voidquicksort(T[] arr)quick sort algorithmstatic <T extends Comparable<? super T>>
voidshellSort(T[] arr)shell sort algorithm
-
-
-
Method Detail
-
insertionSort
public static <T extends Comparable<? super T>> void insertionSort(T[] arr)
insert sort method- Parameters:
arr- an array of a comparable items
-
shellSort
public static <T extends Comparable<? super T>> void shellSort(T[] arr)
shell sort algorithm- Parameters:
arr- an array of Comparable items
-
mergeSort
public static <T extends Comparable<? super T>> void mergeSort(T[] arr)
merge sort algorithm- Parameters:
arr- an array of Comparable item
-
quicksort
public static <T extends Comparable<? super T>> void quicksort(T[] arr)
quick sort algorithm- Parameters:
arr- an array of Comparable items
-
insertionSort
public static <T extends Comparable<? super T>> void insertionSort(T[] arr, int start, int end)
method to sort an subarray from start to end with insertion sort algorithm- Parameters:
arr- an array of Comparable itemsstart- the begining positionend- the end position
-
quickSelect
public static <T extends Comparable<? super T>> void quickSelect(T[] arr, int k)
quick select algorithm- Parameters:
arr- an array of Comparable itemsk- the k-th small index
-
bucketSort
public static void bucketSort(int[] arr, int m)bucket sort algorithm- Parameters:
arr- an int arraym- the large-most one for all the Integers in arr
-
bucketSort
public static void bucketSort(Integer[] arr, int m)
bucket sort algorithm- Parameters:
arr- an array of Integer itemsm- the large-most one for all the Integers in arr
-
-