Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## prea.util
Class Sort

    java.lang.Object
      prea.util.Sort

    public class Sort

extends java.lang.Object

This is a class implementing sort functions in various data type.

Since:
  2012. 4. 20
Version:
  1.1
Author:
  Joonseok Lee

Constructor Summary
`Sort()`

Method Summary
`static void` | `kLargest(double[] array1, int[] array2, int first, int last, int k)` Return k largest elements (sorted) and their indices from a given array.
`static void` | `kSmallest(double[] array1, int[] array2, int first, int last, int k)` Return k smallest elements (sorted) and their indices from a given array.
`private static int` | `partition(double[] array1, int[] array2, int first, int last, boolean increasingOrder)` Partition the given array into two section: smaller and larger than threshold.
`private static int` | `partition(int[] array1, double[] array2, int first, int last, boolean increasingOrder)` Partition the given array into two section: smaller and larger than threshold.
`private static int` | `partition(int[] array1, int[] array2, int first, int last, boolean increasingOrder)` Partition the given array into two section: smaller and larger than threshold.
`private static int` | `partition(int[] array, int first, int last, boolean increasingOrder)` Partition the given array into two section: smaller and larger than threshold.
`static void` | `quickSort(double[] array1, int[] array2, int first, int last, boolean increasingOrder)` Sort the given array, and returns original index as well.
`static void` | `quickSort(int[] array1, double[] array2, int first, int last, boolean increasingOrder)` Sort the given array, and returns original index as well.
`static void` | `quickSort(int[] array1, int[] array2, int first, int last, boolean increasingOrder)` Sort the given array, and returns original index as well.
`static void` | `quickSort(int[] array, int first, int last, boolean increasingOrder)` Sort the given array.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Sort

    public Sort()

Method Detail

### kLargest

    public static void kLargest(double[] array1,
                                int[] array2,
                                int first,
                                int last,
                                int k)

  Return k largest elements (sorted) and their indices from a given array. The original array will be changed, so refer to the first k element of array1 and array2 after calling this method.

  Parameters:
    `array1` - original array of data elements
    `array2` - original array containing data index
    `first` - the first element in the array. Use 0 to deal with the whole array.
    `last` - the last element in the array. Use the maximum index of the array to deal with the whole array.
    `k` - the number of items

### kSmallest

    public static void kSmallest(double[] array1,
                                 int[] array2,
                                 int first,
                                 int last,
                                 int k)

  Return k smallest elements (sorted) and their indices from a given array. The original array will be changed, so refer to the first k element of array1 and array2 after calling this method.

  Parameters:
    `array1` - original array of data elements
    `array2` - original array containing data index
    `first` - the first element in the array. Use 0 to deal with the whole array.
    `last` - the last element in the array. Use the maximum index of the array to deal with the whole array.
    `k` - the number of items

### quickSort

    public static void quickSort(int[] array,
                                 int first,
                                 int last,
                                 boolean increasingOrder)

  Sort the given array. The original array will be sorted.

  Parameters:
    `array` - original array of data elements
    `first` - the first element to be sorted in the array. Use 0 for sorting the whole array.
    `last` - the last element to be sorted in the array. Use the maximum index of the array for sorting the whole array.
    `increasingOrder` - indicating the sort is in increasing order. Use true for increasing order, false for decreasing order.

### quickSort

    public static void quickSort(double[] array1,
                                 int[] array2,
                                 int first,
                                 int last,
                                 boolean increasingOrder)

  Sort the given array, and returns original index as well. The original array will be sorted.

  Parameters:
    `array1` - original array of data elements
    `array2` - original array containing data index
    `first` - the first element to be sorted in the array. Use 0 for sorting the whole array.
    `last` - the last element to be sorted in the array. Use the maximum index of the array for sorting the whole array.
    `increasingOrder` - indicating the sort is in increasing order. Use true for increasing order, false for decreasing order.

### quickSort

    public static void quickSort(int[] array1,
                                 int[] array2,
                                 int first,
                                 int last,
                                 boolean increasingOrder)

  Sort the given array, and returns original index as well. The original array will be sorted.

  Parameters:
    `array1` - original array of data elements of type int
    `array2` - original array containing data index
    `first` - the first element to be sorted in the array. Use 0 for sorting the whole array.
    `last` - the last element to be sorted in the array. Use the maximum index of the array for sorting the whole array.
    `increasingOrder` - indicating the sort is in increasing order. Use true for increasing order, false for decreasing order.

### quickSort

    public static void quickSort(int[] array1,
                                 double[] array2,
                                 int first,
                                 int last,
                                 boolean increasingOrder)

  Sort the given array, and returns original index as well. The original array will be sorted.

  Parameters:
    `array1` - original array of data elements of type int
    `array2` - original array containing data of type double
    `first` - the first element to be sorted in the array. Use 0 for sorting the whole array.
    `last` - the last element to be sorted in the array. Use the maximum index of the array for sorting the whole array.
    `increasingOrder` - indicating the sort is in increasing order. Use true for increasing order, false for decreasing order.

### partition

    private static int partition(int[] array,
                                 int first,
                                 int last,
                                 boolean increasingOrder)

  Partition the given array into two section: smaller and larger than threshold. The threshold is selected from the first element of original array.

  Parameters:
    `array` - original array of data elements
    `first` - the first element in the array
    `last` - the last element in the array
    `increasingOrder` - indicating the sort is in increasing order. Use true for increasing order, false for decreasing order.
  Returns:
    the index of threshold item after partitioning

### partition

    private static int partition(double[] array1,
                                 int[] array2,
                                 int first,
                                 int last,
                                 boolean increasingOrder)

  Partition the given array into two section: smaller and larger than threshold. The threshold is selected from the first element of original array.

  Parameters:
    `array1` - original array of data elements
    `array2` - original array containing data index
    `first` - the first element in the array
    `last` - the last element in the array
    `increasingOrder` - indicating the sort is in increasing order. Use true for increasing order, false for decreasing order.
  Returns:
    the index of threshold item after partitioning

### partition

    private static int partition(int[] array1,
                                 int[] array2,
                                 int first,
                                 int last,
                                 boolean increasingOrder)

  Partition the given array into two section: smaller and larger than threshold. The threshold is selected from the first element of original array.

  Parameters:
    `array1` - original array of data elements of type int
    `array2` - original array containing data index
    `first` - the first element in the array
    `last` - the last element in the array
    `increasingOrder` - indicating the sort is in increasing order. Use true for increasing order, false for decreasing order.
  Returns:
    the index of threshold item after partitioning

### partition

    private static int partition(int[] array1,
                                 double[] array2,
                                 int first,
                                 int last,
                                 boolean increasingOrder)

  Partition the given array into two section: smaller and larger than threshold. The threshold is selected from the first element of original array.

  Parameters:
    `array1` - original array of data elements of type int
    `array2` - original array containing data of type double
    `first` - the first element in the array
    `last` - the last element in the array
    `increasingOrder` - indicating the sort is in increasing order. Use true for increasing order, false for decreasing order.
  Returns:
    the index of threshold item after partitioning

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD