import sort.InsertionSort; import sort.QuickSort; import sort.Sort; import sort.SortableArray; import sort.SortableDataStatistic; import sort.SortableDataTracer; /* * Created on 24 oct. 2004 * */ /** * @author baudon * */ public class TestSort { public static void main(String[] args) { Sort[] sorts = { new QuickSort(), new InsertionSort() }; for (int i = 0; i < sorts.length; i++) { String[] argsCopy = new String[args.length]; System.arraycopy(args, 0, argsCopy, 0, args.length); SortableDataStatistic statData = new SortableDataStatistic( new SortableDataTracer(new SortableArray(argsCopy))); sorts[i].doSort(statData); for (int j = 0; j < args.length; ++j) { System.out.print(argsCopy[j] + " "); } System.out.println(); System.out.println(statData.getCompareStat() + " compare, " + statData.getSwapStat() + " swap"); } } }