Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

jmat.data.arrayTools
Class Sort  view Sort download Sort.java

java.lang.Object
  extended byjmat.data.arrayTools.Sort

public class Sort
extends java.lang.Object

Quick Sort algoritm.

Allows to sort a column quickly, Using a generic version of C.A.R Hoare's Quick Sort algorithm.


Field Summary
private  double[] A
          Array for internal storage of the matrix to sort.
private  int[] order
          Array for internal storage of the order.
 
Constructor Summary
Sort(double[] a)
          Construct an ascending order.
 
Method Summary
 int getOrder(int i)
          Get the ascending order of one line.
private  void QuickSort(double[] a, int lo0, int hi0)
          This is a generic version of C.A.R Hoare's Quick Sort algorithm.
private  void sort(double[] a)
           
private  void swap(double[] a, int i, int j)
          Swap two positions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

A

private double[] A
Array for internal storage of the matrix to sort.


order

private int[] order
Array for internal storage of the order.

Constructor Detail

Sort

public Sort(double[] a)
Construct an ascending order.

Method Detail

getOrder

public int getOrder(int i)
Get the ascending order of one line.


QuickSort

private void QuickSort(double[] a,
                       int lo0,
                       int hi0)
This is a generic version of C.A.R Hoare's Quick Sort algorithm. This will handle arrays that are already sorted, and arrays with duplicate keys.
If you think of a one dimensional array as going from the lowest index on the left to the highest index on the right then the parameters to this methodName are lowest index or left and highest index or right. The first time you call this methodName it will be with the parameters 0, a.length - 1.


sort

private void sort(double[] a)

swap

private void swap(double[] a,
                  int i,
                  int j)
Swap two positions.