Arrays.parallelSort(…)

In Java 8 sind neue Sortiermethoden hinzugekommen, die für sehr große Felder geeignet sind. Bei den neuen parallelSort(…)-Methoden verwendet die Bibliothek mehrere Threads um Teile parallel zu sortieren, was die Geschwindigkeit erhöhen kann. Eine Garantie ist das aber nicht, denn ein Performance-Vorteil ergibt sich wirklich nur bei großen Feldern.

class java.util.Arrays

§ static void parallelSort(byte[] a)

§ static void parallelSort(byte[] a, int fromIndex, int toIndex)

§ static void parallelSort(char[] a)

§ static void parallelSort(char[] a, int fromIndex, int toIndex)

§ static void parallelSort(short[] a)

§ static void parallelSort(short[] a, int fromIndex, int toIndex)

§ static void parallelSort(int[] a)

§ static void parallelSort(int[] a, int fromIndex, int toIndex)

§ static void parallelSort(long[] a)

§ static void parallelSort(long[] a, int fromIndex, int toIndex)

§ static void parallelSort(float[] a)

§ static void parallelSort(float[] a, int fromIndex, int toIndex)

§ static void parallelSort(double[] a)

§ static void parallelSort(double[] a, int fromIndex, int toIndex)

§ static <T extends Comparable<? super T>> void parallelSort(T[] a)

§ static <T extends Comparable<? super T>> void parallelSort(T[] a, int fromIndex, int toIndex)

§ static <T> void parallelSort(T[] a, Comparator<? super T> c)

§ static <T> void parallelSort(T[] a, int fromIndex, int toIndex, Comparator<? super T> c)

Der verwendete Algorithmus ist einfach zu verstehen: zunächst wird das Feld ist Teilfelder partitioniert, die werden dann parallel sortiert und dann zu einem größeren sortierten Feld zusammengelegt. Das Verfahren nennt sich auch parallel sort-merge.

Ähnliche Beiträge

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert