Package tnx.lab.executor
Class XQuicksort
java.lang.Object
tnx.lab.executor.XQuicksort
An implementation of the quicksort algorithm that uses Java's Executors.
- Author:
- __STUDENT_NAME__, Finn Voichick
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidparallelQuicksort(ExecutorService executor, int[] data, IntPredicate isParallelPredicate, Partitioner partitioner)static voidsequentialQuicksort(int[] data, Partitioner partitioner)
-
Constructor Details
-
XQuicksort
public XQuicksort()
-
-
Method Details
-
sequentialQuicksort
public static void sequentialQuicksort(int[] data, Partitioner partitioner) throws InterruptedException, ExecutionException- Parameters:
data- the array to sort in placepartitioner- the partitioner to use for the quicksort algorithm- Throws:
InterruptedException- if the computation was cancelledExecutionException- if the computation threw an exception
-
parallelQuicksort
public static void parallelQuicksort(ExecutorService executor, int[] data, IntPredicate isParallelPredicate, Partitioner partitioner) throws InterruptedException, ExecutionException- Parameters:
executor- anExecutorServicethat you should use to submit tasksdata- the array to sortisParallelPredicate- Predicate whose test method will return whether or not the current range length is large enough to justify running in parallel.partitioner- the partitioner to use for the quicksort algorithm- Throws:
InterruptedException- if the computation was cancelledExecutionException- if the computation threw an exception
-