Heap { public static <T> void heapsort(List<T> A, Comparator<T> comp) { new Heap<T>().heapsort(A, comp, A.size()); }  static void heapsort(List<T> A, Comparator<T> comp); static void heapsort(List<Integer> A); void heapsort(List<T> A, Comparator<T> comp, int n); void maxHeapify(List<T> A, Comparator<T> comp, int i, int n); void buildMaxHeap(List<T> A, Comparator<T> comp, int n);  }
@Test public void testHeapsort() { System.out.println("testHeapsort entry."); List<Integer> before = Arrays.asList(4, 1, 3, 2, 16, 9, 10, 14, 8, 7); List<Integer> expected = Arrays.asList(1, 2, 3, 4, 7, 8, 9, 10, 14, 16); List<Integer> after = new ArrayList<Integer>(before.size()); for(Integer i: before) after.add(i); Heap.heapsort(after); System.out.println("after: " + after); assertArrayEquals(expected.toArray(), after.toArray()); }