Class XQuicksort

java.lang.Object
tnx.lab.executor.XQuicksort

public final class XQuicksort extends Object
An implementation of the quicksort algorithm that uses Java's Executors.
Author:
__STUDENT_NAME__, Finn Voichick
  • 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 place
      partitioner - the partitioner to use for the quicksort algorithm
      Throws:
      InterruptedException - if the computation was cancelled
      ExecutionException - if the computation threw an exception
    • parallelQuicksort

      public static void parallelQuicksort​(ExecutorService executor, int[] data, IntPredicate isParallelPredicate, Partitioner partitioner) throws InterruptedException, ExecutionException
      Parameters:
      executor - an ExecutorService that you should use to submit tasks
      data - the array to sort
      isParallelPredicate - 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 cancelled
      ExecutionException - if the computation threw an exception