Package edu.rit.util

Class Sorting

java.lang.Object
edu.rit.util.Sorting

public class Sorting extends Object
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 Classes
    Modifier and Type
    Class
    Description
    static class 
    Class Sorting.Byte is the base class for a helper object used to sort an array of type byte[].
    static class 
    Class Sorting.Character is the base class for a helper object used to sort an array of type char[].
    static class 
    Class Sorting.Double is the base class for a helper object used to sort an array of type double[].
    static class 
    Class Sorting.Float is the base class for a helper object used to sort an array of type float[].
    static class 
    Class Sorting.Integer is the base class for a helper object used to sort an array of type int[].
    static class 
    Class Sorting.Long is the base class for a helper object used to sort an array of type long[].
    static class 
    Class Sorting.Object is the abstract base class for a helper object used to sort an array of objects of type T[].
    static class 
    Class Sorting.Short is the base class for a helper object used to sort an array of type short[].
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    sort(byte[] x, Sorting.Byte helper)
    Sort the given array of type byte[].
    static char[]
    sort(char[] x, Sorting.Character helper)
    Sort the given array of type char[].
    static double[]
    sort(double[] x, Sorting.Double helper)
    Sort the given array of type double[].
    static float[]
    sort(float[] x, Sorting.Float helper)
    Sort the given array of type float[].
    static int[]
    sort(int[] x, Sorting.Integer helper)
    Sort the given array of type int[].
    static long[]
    sort(long[] x, Sorting.Long helper)
    Sort the given array of type long[].
    static short[]
    sort(short[] x, Sorting.Short helper)
    Sort the given array of type short[].
    static <T> T[]
    sort(T[] x, Sorting.Object<T> helper)
    Sort the given object array of type T[].

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • sort

      public static byte[] sort(byte[] x, Sorting.Byte helper)
      Sort the given array of type byte[]. 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

      public static char[] sort(char[] x, Sorting.Character helper)
      Sort the given array of type char[]. 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

      public static short[] sort(short[] x, Sorting.Short helper)
      Sort the given array of type short[]. 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

      public static int[] sort(int[] x, Sorting.Integer helper)
      Sort the given array of type int[]. 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

      public static long[] sort(long[] x, Sorting.Long helper)
      Sort the given array of type long[]. 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

      public static float[] sort(float[] x, Sorting.Float helper)
      Sort the given array of type float[]. 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

      public static double[] sort(double[] x, Sorting.Double helper)
      Sort the given array of type double[]. 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

      public static <T> T[] sort(T[] x, Sorting.Object<T> helper)
      Sort the given object array of type T[]. 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).