|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstresstests.algorithms.ASortAlgo<T>
stresstests.algorithms.AListSortQuickSort<T>
public class AListSortQuickSort<T>
AListSortQuickSort 22 March 2007 A class to implement quicksort in a functional style with input and the result stored as recursively defined list
Field Summary | |
---|---|
Traversal<T> |
tr
the Traversal that supplies the data to sort |
Fields inherited from class stresstests.algorithms.ASortAlgo |
---|
algoName, comp |
Constructor Summary | |
---|---|
AListSortQuickSort(java.util.Comparator<T> comp)
|
|
AListSortQuickSort(java.util.Comparator<T> comp,
Traversal<T> tr)
|
Method Summary | |
---|---|
private AList<T> |
append(Traversal<T> lowerTr,
T pivot,
AList<T> upper)
Append two lists with the pivot in the middle |
private AList<T> |
appendLists(AList<T> lower,
T pivot,
AList<T> upper)
Wrapper to append two lists with the pivot in the middle: invokes the real method by converting the first AList
to a Traversal |
void |
initData(Traversal<T> tr)
Initialize the internal data set with the data generated by the Traversal |
private AList<T> |
lower(Traversal<T> source,
T pivot)
Produce the lower partition - where all data <= pivot |
static void |
main(java.lang.String[] argv)
|
AList<T> |
quickSort(AList<T> source)
A wrapper for a quicksort for a recursively defined list: it invokes the actual algorithm with the input converted to a Traversal |
AList<T> |
quickSort(Traversal<T> tr)
Quicksort for a recursively defined list |
Traversal<T> |
sort()
wrapper for the sort method |
void |
testAListSortQuick()
The tests for AListSortQuick |
private AList<T> |
upper(Traversal<T> source,
T pivot)
Produce the upper partition - where all data > pivot |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Traversal<T> tr
Traversal
that supplies the data to sort
Constructor Detail |
---|
public AListSortQuickSort(java.util.Comparator<T> comp, Traversal<T> tr)
public AListSortQuickSort(java.util.Comparator<T> comp)
Method Detail |
---|
public void initData(Traversal<T> tr)
Traversal
initData
in class ASortAlgo<T>
tr
- the Traversal
that provides the data to sortpublic Traversal<T> sort()
sort
in class ASortAlgo<T>
Traversal
for the sorted datapublic AList<T> quickSort(AList<T> source)
A wrapper for a quicksort for a recursively defined list:
it invokes the actual algorithm with the input converted
to a Traversal
source
- the AList
to be sorted
return the sorted AList
public AList<T> quickSort(Traversal<T> tr)
Quicksort for a recursively defined list
tr
- the Traversal
that generates
the data to be sorted
return the sorted AList
private AList<T> lower(Traversal<T> source, T pivot)
source
- the Traversal
that generates
the data to be partitionedpivot
- the pivot that determines which data items to choose
return an AList
that contains all data <= pivotprivate AList<T> upper(Traversal<T> source, T pivot)
source
- the Traversal
that generates
the data to be partitionedpivot
- the pivot that determines which data items to choose
return an AList
that contains all data > pivotprivate AList<T> appendLists(AList<T> lower, T pivot, AList<T> upper)
AList
to a Traversal
lower
- the AList
for the lower partitionpivot
- the pivot to insert in the middleupper
- the AList
for the upper partition
return the sorted listprivate AList<T> append(Traversal<T> lowerTr, T pivot, AList<T> upper)
lowerTr
- the traversal
for the lower partitionpivot
- the pivot to insert in the middleupper
- the AList
for the upper partition
return the sorted listpublic void testAListSortQuick()
AListSortQuick
public static void main(java.lang.String[] argv)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |