April 2017
Beginner
504 pages
14h 11m
English
Having done all this, the last thing we will need is to have QuickSort as a simple class (all the real work was already done in different classes).
public class QuickSort<E> implements Sort<E> { public void sort(SortableCollection<E> sortable) { int n = sortable.size(); Qsort<E> qsort = new Qsort<>(comparator,swapper); qsort.qsort(sortable, 0, n-1); } // ... setter injectors were deleted from the print }
Do not forget that we also need a test! But, in this case, that is not much different than that of BubbleSort.
@Test public void canSortStrings() { final String[] actualNames = new String[]{ "Johnson", "Wilson", "Wilkinson", "Abraham", "Dagobert" }; final String[] expected = new String[]{"Abraham", ...Read now
Unlock full access