Java Code Examples for java.util.Arrays#parallelSort()
The following examples show how to use
java.util.Arrays#parallelSort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SortedOps.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper, Spliterator<P_IN> spliterator, IntFunction<Double[]> generator) { if (StreamOpFlag.SORTED.isKnown(helper.getStreamAndOpFlags())) { return helper.evaluate(spliterator, false, generator); } else { Node.OfDouble n = (Node.OfDouble) helper.evaluate(spliterator, true, generator); double[] content = n.asPrimitiveArray(); Arrays.parallelSort(content); return Nodes.node(content); } }
Example 2
Source File: ParallelSorting.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void testEmptyAndNullCharArray() { ourDescription = "Check empty and null array"; Arrays.parallelSort(new char[]{}); Arrays.parallelSort(new char[]{}, 0, 0); try { Arrays.parallelSort((char[]) null); } catch (NullPointerException expected) { try { Arrays.parallelSort((char[]) null, 0, 0); } catch (NullPointerException expected2) { return; } failed("Arrays.parallelSort(char[],fromIndex,toIndex) shouldn't " + "catch null array"); } failed("Arrays.parallelSort(char[]) shouldn't catch null array"); }
Example 3
Source File: ParallelSorting.java From native-obfuscator with GNU General Public License v3.0 | 6 votes |
private static void testEmptyAndNullDoubleArray() { ourDescription = "Check empty and null array"; Arrays.parallelSort(new double[]{}); Arrays.parallelSort(new double[]{}, 0, 0); try { Arrays.parallelSort((double[]) null); } catch (NullPointerException expected) { try { Arrays.parallelSort((double[]) null, 0, 0); } catch (NullPointerException expected2) { return; } failed("Arrays.parallelSort(double[],fromIndex,toIndex) shouldn't " + "catch null array"); } failed("Arrays.parallelSort(double[]) shouldn't catch null array"); }
Example 4
Source File: ParallelSorting.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void testEmptyAndNullLongArray() { ourDescription = "Check empty and null array"; Arrays.parallelSort(new long[]{}); Arrays.parallelSort(new long[]{}, 0, 0); try { Arrays.parallelSort((long[]) null); } catch (NullPointerException expected) { try { Arrays.parallelSort((long[]) null, 0, 0); } catch (NullPointerException expected2) { return; } failed("Arrays.parallelSort(long[],fromIndex,toIndex) shouldn't " + "catch null array"); } failed("Arrays.parallelSort(long[]) shouldn't catch null array"); }
Example 5
Source File: SortedOps.java From j2objc with Apache License 2.0 | 6 votes |
@Override public <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper, Spliterator<P_IN> spliterator, IntFunction<Integer[]> generator) { if (StreamOpFlag.SORTED.isKnown(helper.getStreamAndOpFlags())) { return helper.evaluate(spliterator, false, generator); } else { Node.OfInt n = (Node.OfInt) helper.evaluate(spliterator, true, generator); int[] content = n.asPrimitiveArray(); Arrays.parallelSort(content); return Nodes.node(content); } }
Example 6
Source File: SortedOps.java From Java8CN with Apache License 2.0 | 6 votes |
@Override public <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper, Spliterator<P_IN> spliterator, IntFunction<Long[]> generator) { if (StreamOpFlag.SORTED.isKnown(helper.getStreamAndOpFlags())) { return helper.evaluate(spliterator, false, generator); } else { Node.OfLong n = (Node.OfLong) helper.evaluate(spliterator, true, generator); long[] content = n.asPrimitiveArray(); Arrays.parallelSort(content); return Nodes.node(content); } }
Example 7
Source File: ParallelSorting.java From native-obfuscator with GNU General Public License v3.0 | 6 votes |
private static void testEmptyAndNullFloatArray() { ourDescription = "Check empty and null array"; Arrays.parallelSort(new float[]{}); Arrays.parallelSort(new float[]{}, 0, 0); try { Arrays.parallelSort((float[]) null); } catch (NullPointerException expected) { try { Arrays.parallelSort((float[]) null, 0, 0); } catch (NullPointerException expected2) { return; } failed("Arrays.parallelSort(float[],fromIndex,toIndex) shouldn't " + "catch null array"); } failed("Arrays.parallelSort(float[]) shouldn't catch null array"); }
Example 8
Source File: ParallelSorting.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void testEmptyAndNullLongArray() { ourDescription = "Check empty and null array"; Arrays.parallelSort(new long[]{}); Arrays.parallelSort(new long[]{}, 0, 0); try { Arrays.parallelSort((long[]) null); } catch (NullPointerException expected) { try { Arrays.parallelSort((long[]) null, 0, 0); } catch (NullPointerException expected2) { return; } failed("Arrays.parallelSort(long[],fromIndex,toIndex) shouldn't " + "catch null array"); } failed("Arrays.parallelSort(long[]) shouldn't catch null array"); }
Example 9
Source File: SortedOps.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper, Spliterator<P_IN> spliterator, IntFunction<T[]> generator) { // If the input is already naturally sorted and this operation // naturally sorts then collect the output if (StreamOpFlag.SORTED.isKnown(helper.getStreamAndOpFlags()) && isNaturalSort) { return helper.evaluate(spliterator, false, generator); } else { // @@@ Weak two-pass parallel implementation; parallel collect, parallel sort T[] flattenedData = helper.evaluate(spliterator, true, generator).asArray(generator); Arrays.parallelSort(flattenedData, comparator); return Nodes.node(flattenedData); } }
Example 10
Source File: SortedOps.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper, Spliterator<P_IN> spliterator, IntFunction<T[]> generator) { // If the input is already naturally sorted and this operation // naturally sorts then collect the output if (StreamOpFlag.SORTED.isKnown(helper.getStreamAndOpFlags()) && isNaturalSort) { return helper.evaluate(spliterator, false, generator); } else { // @@@ Weak two-pass parallel implementation; parallel collect, parallel sort T[] flattenedData = helper.evaluate(spliterator, true, generator).asArray(generator); Arrays.parallelSort(flattenedData, comparator); return Nodes.node(flattenedData); } }
Example 11
Source File: SortedOps.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper, Spliterator<P_IN> spliterator, IntFunction<T[]> generator) { // If the input is already naturally sorted and this operation // naturally sorts then collect the output if (StreamOpFlag.SORTED.isKnown(helper.getStreamAndOpFlags()) && isNaturalSort) { return helper.evaluate(spliterator, false, generator); } else { // @@@ Weak two-pass parallel implementation; parallel collect, parallel sort T[] flattenedData = helper.evaluate(spliterator, true, generator).asArray(generator); Arrays.parallelSort(flattenedData, comparator); return Nodes.node(flattenedData); } }
Example 12
Source File: ParallelSorting.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkRange(byte[] a, int m) { try { Arrays.parallelSort(a, m + 1, m); failed("ParallelSort does not throw IllegalArgumentException " + " as expected: fromIndex = " + (m + 1) + " toIndex = " + m); } catch (IllegalArgumentException iae) { try { Arrays.parallelSort(a, -m, a.length); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: fromIndex = " + (-m)); } catch (ArrayIndexOutOfBoundsException aoe) { try { Arrays.parallelSort(a, 0, a.length + m); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: toIndex = " + (a.length + m)); } catch (ArrayIndexOutOfBoundsException aie) { return; } } } }
Example 13
Source File: ParallelSorting.java From native-obfuscator with GNU General Public License v3.0 | 5 votes |
private static void checkRange(int[] a, int m) { try { Arrays.parallelSort(a, m + 1, m); failed("ParallelSort does not throw IllegalArgumentException " + " as expected: fromIndex = " + (m + 1) + " toIndex = " + m); } catch (IllegalArgumentException iae) { try { Arrays.parallelSort(a, -m, a.length); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: fromIndex = " + (-m)); } catch (ArrayIndexOutOfBoundsException aoe) { try { Arrays.parallelSort(a, 0, a.length + m); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: toIndex = " + (a.length + m)); } catch (ArrayIndexOutOfBoundsException aie) { return; } } } }
Example 14
Source File: ParallelSorting.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void checkRange(short[] a, int m) { try { Arrays.parallelSort(a, m + 1, m); failed("ParallelSort does not throw IllegalArgumentException " + " as expected: fromIndex = " + (m + 1) + " toIndex = " + m); } catch (IllegalArgumentException iae) { try { Arrays.parallelSort(a, -m, a.length); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: fromIndex = " + (-m)); } catch (ArrayIndexOutOfBoundsException aoe) { try { Arrays.parallelSort(a, 0, a.length + m); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: toIndex = " + (a.length + m)); } catch (ArrayIndexOutOfBoundsException aie) { return; } } } }
Example 15
Source File: SortComparisonUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenIntegerArrayOf100000Elements_whenUsingArraysParallelSortMethod_thenSortFullArrayInAscendingOrder() { int[] parallelDataSet = Arrays.copyOf(_100000_elements_array, _100000_elements_array.length); Arrays.parallelSort(parallelDataSet); assertNotNull(parallelDataSet); assertNotSame(Arrays.copyOf(_100000_elements_array, _100000_elements_array.length), parallelDataSet); }
Example 16
Source File: ParallelSorting.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkRange(long[] a, int m) { try { Arrays.parallelSort(a, m + 1, m); failed("ParallelSort does not throw IllegalArgumentException " + " as expected: fromIndex = " + (m + 1) + " toIndex = " + m); } catch (IllegalArgumentException iae) { try { Arrays.parallelSort(a, -m, a.length); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: fromIndex = " + (-m)); } catch (ArrayIndexOutOfBoundsException aoe) { try { Arrays.parallelSort(a, 0, a.length + m); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: toIndex = " + (a.length + m)); } catch (ArrayIndexOutOfBoundsException aie) { return; } } } }
Example 17
Source File: ParallelSorting.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void checkRange(char[] a, int m) { try { Arrays.parallelSort(a, m + 1, m); failed("ParallelSort does not throw IllegalArgumentException " + " as expected: fromIndex = " + (m + 1) + " toIndex = " + m); } catch (IllegalArgumentException iae) { try { Arrays.parallelSort(a, -m, a.length); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: fromIndex = " + (-m)); } catch (ArrayIndexOutOfBoundsException aoe) { try { Arrays.parallelSort(a, 0, a.length + m); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: toIndex = " + (a.length + m)); } catch (ArrayIndexOutOfBoundsException aie) { return; } } } }
Example 18
Source File: SortComparisonUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenIntegerArrayOf1000Elements_whenUsingArraysParallelSortMethod_thenSortFullArrayInAscendingOrder() { int[] parallelDataSet = Arrays.copyOf(_1000_elements_array, _1000_elements_array.length); Arrays.parallelSort(parallelDataSet); assertNotNull(parallelDataSet); assertNotSame(Arrays.copyOf(_1000_elements_array, _1000_elements_array.length), parallelDataSet); }
Example 19
Source File: ParallelSorting.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void checkRange(float[] a, int m) { try { Arrays.parallelSort(a, m + 1, m); failed("ParallelSort does not throw IllegalArgumentException " + " as expected: fromIndex = " + (m + 1) + " toIndex = " + m); } catch (IllegalArgumentException iae) { try { Arrays.parallelSort(a, -m, a.length); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: fromIndex = " + (-m)); } catch (ArrayIndexOutOfBoundsException aoe) { try { Arrays.parallelSort(a, 0, a.length + m); failed("ParallelSort does not throw ArrayIndexOutOfBoundsException " + " as expected: toIndex = " + (a.length + m)); } catch (ArrayIndexOutOfBoundsException aie) { return; } } } }
Example 20
Source File: BandSorter.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
static void sort(Band[] allBands) { Arrays.parallelSort(allBands, createComparator()); }