stresstests.algorithms
Class ArrSortQuick<T>

java.lang.Object
  extended by stresstests.algorithms.ASortAlgo<T>
      extended by stresstests.algorithms.ArrSortQuick<T>

public class ArrSortQuick<T>
extends ASortAlgo<T>

ArrSortQuick 22 March 2007 A class to represent one sorting algorithm

Author:
Viera K. Proulx

Field Summary
 java.util.ArrayList<T> data
          data that will be sorted -- mutating sort
 
Fields inherited from class stresstests.algorithms.ASortAlgo
algoName, comp
 
Constructor Summary
ArrSortQuick(java.util.Comparator<T> comp)
           
ArrSortQuick(java.util.Comparator<T> comp, Traversal<T> tr)
           
 
Method Summary
 void initData(Traversal<T> tr)
          Initialize the internal data set with the data generated by the Traversal
static void main(java.lang.String[] argv)
           
static
<T> int
partition(java.util.ArrayList<T> data, java.util.Comparator<T> comp, int min, int max)
          The partition helper function for quick sort and related algorithms.
 void qs(java.util.ArrayList<T> data, java.util.Comparator<T> comp, int min, int max)
           
 java.util.ArrayList<T> quickSortArr(java.util.ArrayList<T> source, java.util.Comparator<T> comp)
           
 Traversal<T> sort()
          sort the data set with respect to the current Comparator
 void testArrSortQuick()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

public java.util.ArrayList<T> data
data that will be sorted -- mutating sort

Constructor Detail

ArrSortQuick

public ArrSortQuick(java.util.Comparator<T> comp,
                    Traversal<T> tr)

ArrSortQuick

public ArrSortQuick(java.util.Comparator<T> comp)
Method Detail

initData

public void initData(Traversal<T> tr)
Initialize the internal data set with the data generated by the Traversal

Specified by:
initData in class ASortAlgo<T>
Parameters:
tr - the Traversal that provides the data to sort

sort

public Traversal<T> sort()
sort the data set with respect to the current Comparator

Specified by:
sort in class ASortAlgo<T>
Returns:
a AList for the sorted data

quickSortArr

public java.util.ArrayList<T> quickSortArr(java.util.ArrayList<T> source,
                                           java.util.Comparator<T> comp)

qs

public void qs(java.util.ArrayList<T> data,
               java.util.Comparator<T> comp,
               int min,
               int max)

partition

public static <T> int partition(java.util.ArrayList<T> data,
                                java.util.Comparator<T> comp,
                                int min,
                                int max)
The partition helper function for quick sort and related algorithms. If min < max then partition the data between min and max and return s such that: min <= s < max if min <= u <= s and s+1 <= v <= max then data[u] <= data[v]


testArrSortQuick

public void testArrSortQuick()

main

public static void main(java.lang.String[] argv)