org.ddogleg.sorting
Class CountingSort
- java.lang.Object
-
- org.ddogleg.sorting.CountingSort
-
public class CountingSort extends java.lang.ObjectA O(N) sorting routine for integer valued elements with a known upper and lower bound. This performance can be obtained since it does not compare elements and instead create a histogram.
-
-
Constructor Summary
Constructors Constructor and Description CountingSort()CountingSort(int minValue, int maxValue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidsetRange(int minValue, int maxValue)Specify the data rangevoidsort(int[] data, int begin, int end)Sorts the data in the array.voidsort(int[] input, int startIndex, int[] output, int startOutput, int length)Sort routine which does not modify the input array.voidsortIndex(int[] input, int start, int length, int[] indexes)Sort routine which does not modify the input array and instead maintains a list of indexes.
-
-
-
Constructor Detail
-
CountingSort
public CountingSort()
-
CountingSort
public CountingSort(int minValue, int maxValue)
-
-
Method Detail
-
setRange
public void setRange(int minValue, int maxValue)Specify the data range- Parameters:
minValue- Minimum allowed value. (inclusive)maxValue- Maximum allowed value. (inclusive)
-
sort
public void sort(int[] data, int begin, int end)Sorts the data in the array.- Parameters:
data- Data which is to be sorted. Sorted data is written back into this same arraybegin- First element to be sorted (inclusive)end- Last element to be sorted (exclusive)
-
sort
public void sort(int[] input, int startIndex, int[] output, int startOutput, int length)Sort routine which does not modify the input array. Input and output arrays can be the same instance.- Parameters:
input- (Input) Data which is to be sorted. Not modified.startIndex- First element in input listoutput- (Output) Sorted data. Modified.length- Number of elements
-
sortIndex
public void sortIndex(int[] input, int start, int length, int[] indexes)Sort routine which does not modify the input array and instead maintains a list of indexes.- Parameters:
input- (Input) Data which is to be sorted. Not modified.start- First element in input listlength- Length of the input listindexes- Number of elements
-
-
DataMelt 3.0 © DataMelt by jWork.ORG