de.caff.util.concurrent

## Class ParallelSort

- java.lang.Object
- - de.caff.util.concurrent.ParallelSort

-     public class ParallelSort
      extends java.lang.Object

  Parallel sorting. This sort algorithm uses multiple threads to sort a list. Whether it is faster or slower than normal sorting is hard to predict, and depends on various factors like cache size etc.
  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ParallelSort()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> void` | `sort(java.util.List<T> list, java.util.Comparator<? super T> comparator, java.util.concurrent.ThreadPoolExecutor executor, int minDivisionSize)` Sort a list by a given comparator using multiple threads.
    `static <T> void` | `sort(java.util.List<T> list, java.util.Comparator<? super T> comparator, java.util.concurrent.ThreadPoolExecutor executor, int maxThreads, int minDivisionSize)` Sort a list by a given comparator using multiple threads.
    `static <T extends java.lang.Comparable<T>> void` | `sort(java.util.List<T> list, java.util.concurrent.ThreadPoolExecutor executor, int minDivisionSize)` Sort a list of comparable items in their natural order using multiple threads.
    `static <T extends java.lang.Comparable<T>> void` | `sort(java.util.List<T> list, java.util.concurrent.ThreadPoolExecutor executor, int maxThreads, int minDivisionSize)` Sort a list of comparable items in their natural order using multiple threads.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ParallelSort

          public ParallelSort()

  - ### Method Detail

    - #### sort

          public static <T extends java.lang.Comparable<T>> void sort(@NotNull
                                                                      java.util.List<T> list,
                                                                      @NotNull
                                                                      java.util.concurrent.ThreadPoolExecutor executor,
                                                                      int minDivisionSize)
                                                               throws java.util.concurrent.ExecutionException,
                                                                      java.lang.InterruptedException

      Sort a list of comparable items in their natural order using multiple threads. This will use all threads of the executor pool.
      Type Parameters:
        `T` - list type
      Parameters:
        `list` - list to sort. Doas not need to be threadsafe unless it is also changed o concurrently outside of this method.
        `executor` - thread pool executor for parallel sort tasks
        `minDivisionSize` - minimal size of a sublist before standard standard sorting is used
      Throws:
        `java.util.concurrent.ExecutionException` - on executor errors
        `java.lang.InterruptedException` - if execution was interrupted

    - #### sort

          public static <T extends java.lang.Comparable<T>> void sort(@NotNull
                                                                      java.util.List<T> list,
                                                                      @NotNull
                                                                      java.util.concurrent.ThreadPoolExecutor executor,
                                                                      int maxThreads,
                                                                      int minDivisionSize)
                                                               throws java.util.concurrent.ExecutionException,
                                                                      java.lang.InterruptedException

      Sort a list of comparable items in their natural order using multiple threads.
      Type Parameters:
        `T` - list type
      Parameters:
        `list` - list to sort. Doas not need to be threadsafe unless it is also changed o concurrently outside of this method.
        `executor` - thread pool executor for parallel sort tasks
        `maxThreads` - maximum number of parallel sort threads
        `minDivisionSize` - minimal size of a sublist before standard standard sorting is used
      Throws:
        `java.util.concurrent.ExecutionException` - on executor errors
        `java.lang.InterruptedException` - if execution was interrupted

    - #### sort

          public static <T> void sort(@NotNull
                                      java.util.List<T> list,
                                      @NotNull
                                      java.util.Comparator<? super T> comparator,
                                      @NotNull
                                      java.util.concurrent.ThreadPoolExecutor executor,
                                      int minDivisionSize)
                               throws java.util.concurrent.ExecutionException,
                                      java.lang.InterruptedException

      Sort a list by a given comparator using multiple threads. This will use all threads of the executor pool.
      Type Parameters:
        `T` - list type
      Parameters:
        `list` - list to sort. Doas not need to be threadsafe unless it is also changed o concurrently outside of this method.
        `comparator` - comparator defining the sort order, has to be threadsafe
        `executor` - thread pool executor for parallel sort tasks
        `minDivisionSize` - minimal size of a sublist before standard standard sorting is used
      Throws:
        `java.util.concurrent.ExecutionException` - on executor errors
        `java.lang.InterruptedException` - if execution was interrupted

    - #### sort

          public static <T> void sort(@NotNull
                                      java.util.List<T> list,
                                      @NotNull
                                      java.util.Comparator<? super T> comparator,
                                      @NotNull
                                      java.util.concurrent.ThreadPoolExecutor executor,
                                      int maxThreads,
                                      int minDivisionSize)
                               throws java.util.concurrent.ExecutionException,
                                      java.lang.InterruptedException

      Sort a list by a given comparator using multiple threads.
      Type Parameters:
        `T` - list type
      Parameters:
        `list` - list to sort. Doas not need to be threadsafe unless it is also changed o concurrently outside of this method.
        `comparator` - comparator defining the sort order, has to be threadsafe
        `executor` - thread pool executor for parallel sort tasks
        `maxThreads` - maximum number of parallel sort threads, a positive integer
        `minDivisionSize` - minimal size of a sublist before standard standard sorting is used
      Throws:
        `java.util.concurrent.ExecutionException` - on executor errors
        `java.lang.InterruptedException` - if execution was interrupted