Package edu.rit.util
Class Sorting
java.lang.Object
edu.rit.util.Sorting
Class Sorting provides static methods for sorting arrays of primitive types
and object types.
Note: The operations in class Sorting are not multiple thread safe.
- Version:
- 02-Nov-2011
- Author:
- Alan Kaminsky
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass Sorting.Byte is the base class for a helper object used to sort an array of typebyte[].static classClass Sorting.Character is the base class for a helper object used to sort an array of typechar[].static classClass Sorting.Double is the base class for a helper object used to sort an array of typedouble[].static classClass Sorting.Float is the base class for a helper object used to sort an array of typefloat[].static classClass Sorting.Integer is the base class for a helper object used to sort an array of typeint[].static classClass Sorting.Long is the base class for a helper object used to sort an array of typelong[].static classClass Sorting.Object is the abstract base class for a helper object used to sort an array of objects of typeT[].static classClass Sorting.Short is the base class for a helper object used to sort an array of typeshort[]. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]sort(byte[] x, Sorting.Byte helper) Sort the given array of typebyte[].static char[]sort(char[] x, Sorting.Character helper) Sort the given array of typechar[].static double[]sort(double[] x, Sorting.Double helper) Sort the given array of typedouble[].static float[]sort(float[] x, Sorting.Float helper) Sort the given array of typefloat[].static int[]sort(int[] x, Sorting.Integer helper) Sort the given array of typeint[].static long[]sort(long[] x, Sorting.Long helper) Sort the given array of typelong[].static short[]sort(short[] x, Sorting.Short helper) Sort the given array of typeshort[].static <T> T[]sort(T[] x, Sorting.Object<T> helper) Sort the given object array of typeT[].
-
Method Details
-
sort
Sort the given array of typebyte[]. The given helper object is used to determine the desired ordering of the array elements and to swap the array elements. An O(n log n) heapsort algorithm is used.- Parameters:
x- Array to be sorted.helper- Helper object.- Returns:
- The array that was sorted (
x).
-
sort
Sort the given array of typechar[]. The given helper object is used to determine the desired ordering of the array elements and to swap the array elements. An O(n log n) heapsort algorithm is used.- Parameters:
x- Array to be sorted.helper- Helper object.- Returns:
- The array that was sorted (
x).
-
sort
Sort the given array of typeshort[]. The given helper object is used to determine the desired ordering of the array elements and to swap the array elements. An O(n log n) heapsort algorithm is used.- Parameters:
x- Array to be sorted.helper- Helper object.- Returns:
- The array that was sorted (
x).
-
sort
Sort the given array of typeint[]. The given helper object is used to determine the desired ordering of the array elements and to swap the array elements. An O(n log n) heapsort algorithm is used.- Parameters:
x- Array to be sorted.helper- Helper object.- Returns:
- The array that was sorted (
x).
-
sort
Sort the given array of typelong[]. The given helper object is used to determine the desired ordering of the array elements and to swap the array elements. An O(n log n) heapsort algorithm is used.- Parameters:
x- Array to be sorted.helper- Helper object.- Returns:
- The array that was sorted (
x).
-
sort
Sort the given array of typefloat[]. The given helper object is used to determine the desired ordering of the array elements and to swap the array elements. An O(n log n) heapsort algorithm is used.- Parameters:
x- Array to be sorted.helper- Helper object.- Returns:
- The array that was sorted (
x).
-
sort
Sort the given array of typedouble[]. The given helper object is used to determine the desired ordering of the array elements and to swap the array elements. An O(n log n) heapsort algorithm is used.- Parameters:
x- Array to be sorted.helper- Helper object.- Returns:
- The array that was sorted (
x).
-
sort
Sort the given object array of typeT[]. The given helper object is used to determine the desired ordering of the array elements and to swap the array elements. An O(n log n) heapsort algorithm is used.- Type Parameters:
T- Data type of the array elements.- Parameters:
x- Array to be sorted.helper- Helper object.- Returns:
- The array that was sorted (
x).
-