O2Plib.misc
Class Sort

java.lang.Object
  extended by O2Plib.misc.Sort

public class Sort
extends java.lang.Object

Class Sort contains utility sort functions for the 2D Open2Dprot program.

This code is derived and refactored from MAExplorer Sort.java and Open2Dprot's Seg2Dgel Sg2sort.java module.

This work was derived from MAExplorer under the Mozilla 1.1 Open Source Public License by Peter Lemkin of the National Cancer Institute, an agency of the United States Government subject to the limitations noted in the accompanying LEGAL file. See licence info on http://maexplorer.sourceforge.org/

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The Open2Dprot Mozilla and Legal files are available on http://Open2Dprot.sourceforge.net/.

Version:
$Date: 2005/10/21 16:33:51 $ $Revision: 1.11 $
Author:
P. Lemkin, NCI-Frederick, Frederick, MD, 21702
See Also:
Open2Dprot Home

Constructor Summary
Sort()
          Sort() - Constructor
 
Method Summary
static java.lang.String[] bubbleSort(java.lang.String[] data, int len)
          bubbleSort() - Sort String array via bubble sort w/len
static int[] bubbleSortIndex(float[] data, int len, boolean ascending)
          bubbleSortIndex() - sort copy of float[0:len-1] data with bubble sort, return index[].
static int[] bubbleSortIndex(int[] data, int len, boolean ascending)
          bubbleSortIndex() - sort copy of int[0:len-1] data with bubble sort, return index[].
static int[] bubbleSortIndex(java.lang.String[] data, int len, boolean ascending)
          bubbleSortIndex() - sort copy of String[0:len-1] data with bubble sort, return index[].
static void quickSort(int[] a, int lo0, int hi0)
          quickSort() - sort the int[] array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sort

public Sort()
Sort() - Constructor

Method Detail

quickSort

public static void quickSort(int[] a,
                             int lo0,
                             int hi0)
quickSort() - sort the int[] array. Based on QuickSort method by James Gosling from Sun's SortDemo applet

Parameters:
a - array of data to sort
lo0 - lower bound of array
hi0 - uppper bound of array

bubbleSort

public static java.lang.String[] bubbleSort(java.lang.String[] data,
                                            int len)
bubbleSort() - Sort String array via bubble sort w/len

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
Returns:
the new sorted string[] array

bubbleSortIndex

public static int[] bubbleSortIndex(java.lang.String[] data,
                                    int len,
                                    boolean ascending)
bubbleSortIndex() - sort copy of String[0:len-1] data with bubble sort, return index[]. Do NOT actually sort the original data[].

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
ascending - sort if true
Returns:
the index[] of the sorted data

bubbleSortIndex

public static int[] bubbleSortIndex(float[] data,
                                    int len,
                                    boolean ascending)
bubbleSortIndex() - sort copy of float[0:len-1] data with bubble sort, return index[]. Do NOT actually sort the original data[].

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
ascending - sort if true
Returns:
the index[] of the sorted data

bubbleSortIndex

public static int[] bubbleSortIndex(int[] data,
                                    int len,
                                    boolean ascending)
bubbleSortIndex() - sort copy of int[0:len-1] data with bubble sort, return index[]. Do NOT actually sort the original data[].

Parameters:
data - array of data to be sorted
len - size of subarray array of data to be sorted [0:len-1]
ascending - sort if true
Returns:
the index[] of the sorted data