Class MJAsort

java.lang.Object
  |
  +--MJAbase
        |
        +--MJAsort

public class MJAsort
extends MJAbase

MAExplorer Open Java API class to access MJAsort methods and data structures. Access builtin sort methods.

List of methods available to Plugin-writers sortStrArray() - create a sorted String[] array. sortStrArray() - create a sorted String[] array with len specified. bubbleSort() - Sort String array via bubble sort. bubbleSort() - Sort String array via bubble sort w/len specified bubbleSortIndex() - sort String data[0:len-1] copy w/bubble sort, bubbleSortIndex() - sort short data[0:len-1] copy w/bubble sort, bubbleSortIndex() - sort int data[0:len-1] copy w/bubble sort, bubbleSortIndex() - sort float data[0:len-1] copy w/bubble sort, uniqueInsertionSort() - insertion sort newStr into sList[] if unique. uniqueInsertionSort() - insertion bubble sort s1,s2 into sList1[], sList2[] sortArray() - bubble sort string array either ASCENDING or DESCENDING. uniqueInsert() - insert s1 at end of sList1[] and UC of s1 in sList1UC[] uniqueInsert() - insert s1,s2 at end of sList1[], sList2[] lists quickSort() - sort the int list a[]. quickSort() - sort the String list a[]. quickSortMultLists() - sort parallel lists (a[], a[UC[]) by aUC[]. quickSortMultLists() - sort parallel lists (a[], b[], aUC[]) by aUC[].


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 MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.

Version:
$Date: 2003/03/28 17:35:40 $ $Revision: 1.6 $
Author:
P. Lemkin (NCI), J. Evans (CIT), C. Santos (CIT), G. Thornwall (SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home


Fields inherited from class MJAbase
COMPARE_ALL, COMPARE_ANY, COMPARE_AT_LEAST, COMPARE_AT_MOST, COMPARE_PRODUCT, COMPARE_SUM, DATA_F1TOT, DATA_F2TOT, DATA_MEAN_F1F2TOT, DATA_RATIO_F1F2TOT, DRAW_BIN, DRAW_BOX, DRAW_CIRCLE, DRAW_PLUS, EDIT_ADD, EDIT_NOP, EDIT_RMV, GENE_ATCC_ID, GENE_BAD_DATA, GENE_BAD_LOCAL_SPOT_BKGRD, GENE_BAD_MID, GENE_BAD_SPOT, GENE_BAD_SPOT_GEOMETRY, GENE_DUP_SPOT, GENE_GOOD_MID, GENE_IMAGE_ID, GENE_IS_CUR_GENE, GENE_IS_EGL_GENE, GENE_IS_FILTERED, GENE_IS_KMEANS, GENE_IS_NOT_FILTERED, GENE_LOW_SPOT_REF_SIGNAL, GENE_MARGINAL_SPOT, GENE_USE_GBID_FOR_CLONEID, HIER_CLUST_NEXT_MIN_LNKG, HIER_CLUST_PGMA_LNKG, HIER_CLUST_PGMC_LNKG, MARKER_CIRCLE, MARKER_CURRENT, MARKER_GENES, MARKER_KMEANS_CLUSTER, MARKER_NONE, MARKER_PLUS, MARKER_SQUARE, MASTER_CLONE_ID, MASTER_DBEST3, MASTER_DBEST5, MASTER_GENBANK, MASTER_GENBANK3, MASTER_GENBANK5, MASTER_GENE_NAME, MASTER_GENERIC_ID, MASTER_LOCUSLINK, MASTER_SWISS_PROT, MASTER_UG_ID, MASTER_UG_NAME, MAX_COLORS, PLOT_CLUSTER_GENES, PLOT_CLUSTER_HIER, PLOT_CLUSTER_HYBSAMPLES, PLOT_CLUSTERGRAM, PLOT_EXPR_PROFILE, PLOT_F1_F2_INTENS, PLOT_F1_F2_MVSA, PLOT_HIST_F1F2_RATIO, PLOT_HIST_HP_XY_RATIO, PLOT_HIST_HP_XY_SETS_RATIO, PLOT_HP_XY_INTENS, PLOT_INTENS_HIST, PLOT_KMEANS_CLUSTERGRAM, PLOT_PSEUDO_F1F2_IMG, PLOT_PSEUDO_F1F2_RYG_IMG, PLOT_PSEUDO_HP_XY_IMG, PLOT_PSEUDO_HP_XY_RYG_IMG, PLOT_PSEUDOIMG, PRPROP_CUR_GENE, PRPROP_FILTER, PRPROP_LABEL, PRPROP_SLIDER, PRPROP_TIMEOUT, PRPROP_UNIQUE, QUALTYPE_ALPHA, QUALTYPE_PROP_CODE, QUALTYPE_THR, RANGE_INSIDE, RANGE_OUTSIDE, RPT_FMT_DYN, RPT_FMT_TAB_DELIM, RPT_NONE, RPT_TBL_ALL_GENES_CLUSTER, RPT_TBL_CALIB_DNA_STAT, RPT_TBL_CUR_GENE_CLUSTER, RPT_TBL_EDITED_GENE_LIST, RPT_TBL_EXPR_PROFILE, RPT_TBL_FILTERED_GENES, RPT_TBL_GENE_CLASS, RPT_TBL_HIER_CLUSTER, RPT_TBL_HIGH_F1F2, RPT_TBL_HIGH_RATIO, RPT_TBL_HP_DB_INFO, RPT_TBL_HP_HP_CORR, RPT_TBL_HP_MN_VAR_STAT, RPT_TBL_HP_XY_SET_STAT, RPT_TBL_KMEANS_CLUSTER, RPT_TBL_LOW_F1F2, RPT_TBL_LOW_RATIO, RPT_TBL_MAE_PRJ_DB, RPT_TBL_MN_KMEANS_CLUSTER, RPT_TBL_NAMED_GENES, RPT_TBL_NORMALIZATION_GENE_LIST, RPT_TBL_OCL_STAT, RPT_TBL_SAMPLES_DB_INFO, RPT_TBL_SAMPLES_WEB_LINKS, SS_MODE_ELIST, SS_MODE_MS, SS_MODE_XANDY_SETS, SS_MODE_XORY_SETS, SS_MODE_XSET, SS_MODE_XY, SS_MODE_YSET
 
Method Summary
 java.lang.String[] bubbleSort(java.lang.String[] data)
          bubbleSort() - Sort String array via bubble sort.
 java.lang.String[] bubbleSort(java.lang.String[] data, int len)
          bubbleSort() - Sort String array via bubble sort w/len specified
 int[] bubbleSortIndex(float[] data, int len, boolean ascending)
          bubbleSortIndex() - sort float data[0:len-1] copy w/bubble sort, return index[]
 int[] bubbleSortIndex(int[] data, int len, boolean ascending)
          bubbleSortIndex() - sort int data[0:len-1] copy w/bubble sort, return index[]
 int[] bubbleSortIndex(short[] data, int len, boolean ascending)
          bubbleSortIndex() - sort int data[0:len-1] copy w/bubble sort, return index[] Do NOT actually sort the original data[].
static int[] bubbleSortIndex(java.lang.String[] data, int len, boolean ascending)
          bubbleSortIndex() - sort String data[0:len-1] copy w/bubble sort, return index[].
 void quickSort(int[] data, int lo0, int hi0)
          quickSort() - sort the int list data[].
 void quickSort(java.lang.String[] data, int lo0, int hi0)
          quickSort() - sort the String list data[].
 void quickSortMultLists(java.lang.String[] data, java.lang.String[] dataUC, int lo0, int hi0)
          quickSortMultLists() - sort parallel lists (data[], data[UC[]) by dataUC[].
 void quickSortMultLists(java.lang.String[] a, java.lang.String[] b, java.lang.String[] aUC, int lo0, int hi0)
          quickSortMultLists() - sort parallel lists (a[], b[], aUC[]) by aUC[].
 java.lang.String[] sortArray(java.lang.String[] data, boolean sortAscending)
          sortArray() - bubble sort string array either ASCENDING or DESCENDING.
 java.lang.String[] sortStrArray(java.lang.String[] unsortedData)
          sortStrArray() - create a sorted String[] array.
 java.lang.String[] sortStrArray(java.lang.String[] unsortedData, int len)
          sortStrArray() - create a sorted String[] array with len specified.
 int uniqueInsert(java.lang.String[] sList1, java.lang.String[] sList1UC, int sListLen, java.lang.String s1, java.util.Hashtable ht)
          uniqueInsert() - insert s1 at end of sList1[] and UC of s1 in sList1UC[] if s1 is not already in sList1[].
 int uniqueInsert(java.lang.String[] sList1, java.lang.String[] sList2, java.lang.String[] sList1UC, int sListLen, java.lang.String s1, java.lang.String s2, java.util.Hashtable ht)
          uniqueInsert() - insert s1,s2 at end of sList1[], sList2[] lists if s1 is not already in sList1[].
 int uniqueInsertionSort(java.lang.String[] sList, java.lang.String[] sListUC, int sListLen, java.lang.String newStr, java.util.Hashtable ht)
          uniqueInsertionSort() - insertion sort newStr into sList[] if unique.
 int uniqueInsertionSort(java.lang.String[] sList1, java.lang.String[] sList2, java.lang.String[] sListUC, int sListLen, java.lang.String s1, java.lang.String s2, java.util.Hashtable ht)
          uniqueInsertionSort() - insertion bubble sort s1,s2 into sList1[], sList2[] if s1 is unique.
 
Methods inherited from class MJAbase
cvtHashtable2SimpleTable, cvtTable2Hashtable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sortStrArray

public final java.lang.String[] sortStrArray(java.lang.String[] unsortedData)
sortStrArray() - create a sorted String[] array.
Parameters:
unsortedData - array of data to be sorted
Returns:
the new sorted string[] array

sortStrArray

public final java.lang.String[] sortStrArray(java.lang.String[] unsortedData,
                                             int len)
sortStrArray() - create a sorted String[] array with len specified.
Parameters:
unsortedData - 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

bubbleSort

public final java.lang.String[] bubbleSort(java.lang.String[] data)
bubbleSort() - Sort String array via bubble sort.
Parameters:
data - array of data to be sorted
Returns:
the new sorted string[] array

bubbleSort

public final java.lang.String[] bubbleSort(java.lang.String[] data,
                                           int len)
bubbleSort() - Sort String array via bubble sort w/len specified
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 final int[] bubbleSortIndex(java.lang.String[] data,
                                          int len,
                                          boolean ascending)
bubbleSortIndex() - sort String data[0:len-1] copy w/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 final int[] bubbleSortIndex(short[] data,
                                   int len,
                                   boolean ascending)
bubbleSortIndex() - sort int data[0:len-1] copy w/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 final int[] bubbleSortIndex(int[] data,
                                   int len,
                                   boolean ascending)
bubbleSortIndex() - sort int data[0:len-1] copy w/bubble sort, return index[]
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 final int[] bubbleSortIndex(float[] data,
                                   int len,
                                   boolean ascending)
bubbleSortIndex() - sort float data[0:len-1] copy w/bubble sort, return index[]
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

uniqueInsertionSort

public final int uniqueInsertionSort(java.lang.String[] sList,
                                     java.lang.String[] sListUC,
                                     int sListLen,
                                     java.lang.String newStr,
                                     java.util.Hashtable ht)
uniqueInsertionSort() - insertion sort newStr into sList[] if unique. Note: this is faster than the bubble sort after the list is constructed.
Parameters:
sList - array of data to be sorted
sListUC - array of parallel uppercase data to be sorted
sListLen - size of subarray of data to be sorted [0:sListLen-1]
newStr - new data to insert
ht - hashtable to use
Returns:
the size of the sorted array with new item inserted

uniqueInsertionSort

public final int uniqueInsertionSort(java.lang.String[] sList1,
                                     java.lang.String[] sList2,
                                     java.lang.String[] sListUC,
                                     int sListLen,
                                     java.lang.String s1,
                                     java.lang.String s2,
                                     java.util.Hashtable ht)
uniqueInsertionSort() - insertion bubble sort s1,s2 into sList1[], sList2[] if s1 is unique. Note: this is faster than the bubble sort after the list is constructed.
Parameters:
sList1 - array of data to be sorted
sList2 - array of data to be sorted
sListUC - array of parallel uppercase data to be sorted
sListLen - size of subarray array of data to sorted [0:sListLen-1]
s1 - new data to insert
s2 - new data to insert
ht - hashtable to use
Returns:
the size of the (possibly modified) list.

sortArray

public final java.lang.String[] sortArray(java.lang.String[] data,
                                          boolean sortAscending)
sortArray() - bubble sort string array either ASCENDING or DESCENDING. This uses a bubble sort. [TODO] extend this to deal with trailing numbers eg. A1, A10, A2 should be sorted as A1, A2, A10. Should be able to use a RuleBasedCollator...
Parameters:
data - array of data to be sorted
sortAscending - direction of sort
Returns:
the sorted list.

uniqueInsert

public final int uniqueInsert(java.lang.String[] sList1,
                              java.lang.String[] sList1UC,
                              int sListLen,
                              java.lang.String s1,
                              java.util.Hashtable ht)
uniqueInsert() - insert s1 at end of sList1[] and UC of s1 in sList1UC[] if s1 is not already in sList1[]. Note: this is to be used with the quickSortMultLists() for these arrays after they are constructed.
Parameters:
sList1 - array of data to be sorted
sListUC - array of parallel uppercase data to be sorted
sListLen - size of subarray array of data to sorted [0:sListLen-1]
newStr - sort if true
Returns:
the size of the (possibly modified) list.

uniqueInsert

public final int uniqueInsert(java.lang.String[] sList1,
                              java.lang.String[] sList2,
                              java.lang.String[] sList1UC,
                              int sListLen,
                              java.lang.String s1,
                              java.lang.String s2,
                              java.util.Hashtable ht)
uniqueInsert() - insert s1,s2 at end of sList1[], sList2[] lists if s1 is not already in sList1[]. Insert UC of s1 into sList1UC[]. Note: this is to be used with the quickSortMultLists() for these arrays after they are constructed.
Parameters:
sList1 - array of data to be sorted
sList2 - array of data to be sorted
sListUC - array of parallel uppercase data to be sorted
sListLen - size of subarray array of data to sorted [0:sListLen-1]
s1 - data to insert
s2 - data to insert
ht - hashtable
Returns:
the size of the (possibly modified) list.

quickSort

public final void quickSort(int[] data,
                            int lo0,
                            int hi0)
quickSort() - sort the int list data[]. Based on QuickSort method by James Gosling from Sun's SortDemo applet
Parameters:
data - array of data to sort
lo0 - lower bound of array
hi0 - uppper bound of array

quickSort

public final void quickSort(java.lang.String[] data,
                            int lo0,
                            int hi0)
quickSort() - sort the String list data[]. Based on QuickSort method by James Gosling from Sun's SortDemo applet.
Parameters:
data - array of data to sort
lo0 - lower bound of array
hi0 - uppper bound of array

quickSortMultLists

public final void quickSortMultLists(java.lang.String[] data,
                                     java.lang.String[] dataUC,
                                     int lo0,
                                     int hi0)
quickSortMultLists() - sort parallel lists (data[], data[UC[]) by dataUC[]. Requires that dataUC[] be data[].toUppercase(). Based on QuickSort method by James Gosling from Sun's SortDemo applet
Parameters:
data - array of data to sort
dataUC - upper case version of array data[]
lo0 - lower bound of array
hi0 - uppper bound of array

quickSortMultLists

public final void quickSortMultLists(java.lang.String[] a,
                                     java.lang.String[] b,
                                     java.lang.String[] aUC,
                                     int lo0,
                                     int hi0)
quickSortMultLists() - sort parallel lists (a[], b[], aUC[]) by aUC[]. Requires that aUC[] be a[].toUppercase(). Based on QuickSort method by James Gosling from Sun's SortDemo applet
Parameters:
a - array of data to sort
b - array of data to sort
aUC - upper case version of array a[]
lo0 - lower bound of array
hi0 - uppper bound of array