Class Quicksort
Sorter
|
+--Quicksort
- public class Quicksort
- extends Sorter
Class for performing "instrumented" quicksort.
(See source code at Quicksort.java.)
| Method Summary |
static void | main(String[] args) Performs simple tests. |
static SortResult | sort(Comparable[] a) Sorts array. |
static SortResult | sort(Object[] a, Comparator c) Sorts array. |
static void | testSort(String testName, Object[] a, Comparator c) Tests sort:
Performs sort, tests result, and prints values of counters, preceded
by header message. |
main
public static void main(String[] args)
- Performs simple tests.
- Parameters:
- args command-line arguments -- data to sort, or none to use
default data
sort
public static SortResult sort(Comparable[] a)
- Sorts array.
- Parameters:
- a array to sort (in compareTo orter)
- Returns: counters showing number of comparisons and number of swaps
sort
public static SortResult sort(Object[] a, Comparator c)
- Sorts array.
- Parameters:
- a array to sort
- c comparator, or null to use array's compareTo method (in which
case its elements should be Comparable)
- Returns: counters showing number of comparisons and number of swaps
testSort
public static void testSort(String testName, Object[] a, Comparator c)
- Tests sort:
Performs sort, tests result, and prints values of counters, preceded
by header message.
- Parameters:
- testName "test name" for header message
- a array to sort
- c comparator, or null to use compareTo