stresstests.algorithms
Class AListSortInsertion<T>

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

public class AListSortInsertion<T>
extends ASortAlgo<T>

AListSortInsertion 22 March 2007 A class to represent insertion sort based on recursively defined list sorting algorithm

Author:
Viera K. Proulx

Field Summary
 java.util.ArrayList<T> result
          the ArrayList to hold the result
 Traversal<T> tr
          the Traversal that supplies the data to sort
 
Fields inherited from class stresstests.algorithms.ASortAlgo
algoName, comp
 
Constructor Summary
AListSortInsertion(java.util.Comparator<T> comp)
           
AListSortInsertion(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
 AList<T> insert(T city, Traversal<T> tr)
          Insert the given item into the given sorted list
 AList<T> insertionSort(Traversal<T> tr)
          sort the data set with respect to the current Comparator
static void main(java.lang.String[] argv)
           
 AList<T> makeList(Traversal<T> tr)
          Build the recursively defined list from the data generated by the given Traversal
 Traversal<T> sort()
          wrapper for the sort method
 void testAListSortInsertion()
          The tests for AListSortInsertion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tr

public Traversal<T> tr
the Traversal that supplies the data to sort


result

public java.util.ArrayList<T> result
the ArrayList to hold the result

Constructor Detail

AListSortInsertion

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

AListSortInsertion

public AListSortInsertion(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()
wrapper for the sort method

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

insertionSort

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

Parameters:
tr - the Traversal for the input data
Returns:
a AList for the sorted data

insert

public AList<T> insert(T city,
                       Traversal<T> tr)
Insert the given item into the given sorted list

Parameters:
city - the object of the type T to insert
tr - the Traversal for the sorted data where to insert
Returns:
the Traversal for the sorted data with the given item inserted

makeList

public AList<T> makeList(Traversal<T> tr)
Build the recursively defined list from the data generated by the given Traversal

Parameters:
tr - the given Traversal
Returns:
the AList that contains the given data

testAListSortInsertion

public void testAListSortInsertion()
The tests for AListSortInsertion


main

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