package student; import java.util.*; import sorting.SortAlgorithm; abstract class SortingHeapSort implements SortAlgorithm{ /** The ArrayList to sort */ public ArrayList alist; /** * Initialize the list to be sorted from the given data. * @param alist the ArrayList to sort */ public void init(ArrayList alistin){ this.alist = new ArrayList(); for (T t: alistin){ this.alist.add(t); } } /** * Sort the given ArrayList using the given * Comparator. Return the sorted result. * For in-place algorithms alist should be * the result. * @param alist the ArrayList to sort * @param comp the Comparator that determines the ordering * @return the sorted ArrayList */ public ArrayList sort(Comparator comp){ return heapsort(this.alist, comp); } abstract public ArrayList heapsort(ArrayList alist, Comparator comp); }