本文整理汇总了Java中java.util.Arrays.parallelSort方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.parallelSort方法的具体用法?Java Arrays.parallelSort怎么用?Java Arrays.parallelSort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Arrays
的用法示例。
在下文中一共展示了Arrays.parallelSort方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: opEvaluateParallel
import java.util.Arrays; //导入方法依赖的package包/类
@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);
}
}
示例2: testEmptyAndNullFloatArray
import java.util.Arrays; //导入方法依赖的package包/类
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");
}
示例3: testEmptyAndNullCharArray
import java.util.Arrays; //导入方法依赖的package包/类
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");
}
示例4: testEmptyAndNullIntArray
import java.util.Arrays; //导入方法依赖的package包/类
private static void testEmptyAndNullIntArray() {
ourDescription = "Check empty and null array";
Arrays.parallelSort(new int[]{});
Arrays.parallelSort(new int[]{}, 0, 0);
try {
Arrays.parallelSort((int[]) null);
} catch (NullPointerException expected) {
try {
Arrays.parallelSort((int[]) null, 0, 0);
} catch (NullPointerException expected2) {
return;
}
failed("Arrays.parallelSort(int[],fromIndex,toIndex) shouldn't " +
"catch null array");
}
failed("Arrays.parallelSort(int[]) shouldn't catch null array");
}
示例5: testEmptyAndNullByteArray
import java.util.Arrays; //导入方法依赖的package包/类
private static void testEmptyAndNullByteArray() {
ourDescription = "Check empty and null array";
Arrays.parallelSort(new byte[]{});
Arrays.parallelSort(new byte[]{}, 0, 0);
try {
Arrays.parallelSort((byte[]) null);
} catch (NullPointerException expected) {
try {
Arrays.parallelSort((byte[]) null, 0, 0);
} catch (NullPointerException expected2) {
return;
}
failed("Arrays.parallelSort(byte[],fromIndex,toIndex) shouldn't " +
"catch null array");
}
failed("Arrays.parallelSort(byte[]) shouldn't catch null array");
}
示例6: testEmptyAndNullDoubleArray
import java.util.Arrays; //导入方法依赖的package包/类
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");
}
示例7: sort
import java.util.Arrays; //导入方法依赖的package包/类
private static void sort(Object object) {
if (object instanceof int[]) {
Arrays.parallelSort((int[]) object);
} else if (object instanceof long[]) {
Arrays.parallelSort((long[]) object);
} else if (object instanceof short[]) {
Arrays.parallelSort((short[]) object);
} else if (object instanceof byte[]) {
Arrays.parallelSort((byte[]) object);
} else if (object instanceof char[]) {
Arrays.parallelSort((char[]) object);
} else if (object instanceof float[]) {
Arrays.parallelSort((float[]) object);
} else if (object instanceof double[]) {
Arrays.parallelSort((double[]) object);
} else if (object instanceof Integer[]) {
Arrays.parallelSort((Integer[]) object);
} else {
failed("Unknow type of array: " + object + " of class " +
object.getClass().getName());
}
}
示例8: sortSubArray
import java.util.Arrays; //导入方法依赖的package包/类
private static void sortSubArray(Object object, int fromIndex, int toIndex) {
if (object instanceof int[]) {
Arrays.parallelSort((int[]) object, fromIndex, toIndex);
} else if (object instanceof long[]) {
Arrays.parallelSort((long[]) object, fromIndex, toIndex);
} else if (object instanceof short[]) {
Arrays.parallelSort((short[]) object, fromIndex, toIndex);
} else if (object instanceof byte[]) {
Arrays.parallelSort((byte[]) object, fromIndex, toIndex);
} else if (object instanceof char[]) {
Arrays.parallelSort((char[]) object, fromIndex, toIndex);
} else if (object instanceof float[]) {
Arrays.parallelSort((float[]) object, fromIndex, toIndex);
} else if (object instanceof double[]) {
Arrays.parallelSort((double[]) object, fromIndex, toIndex);
} else if (object instanceof Integer[]) {
Arrays.parallelSort((Integer[]) object, fromIndex, toIndex);
} else {
failed("Unknow type of array: " + object + " of class " +
object.getClass().getName());
}
}
示例9: run
import java.util.Arrays; //导入方法依赖的package包/类
@Test
public void run() {
/**并行排序*/
int[] arr=new int[10000000];
Arrays.parallelSort(arr);
}
示例10: checkRange
import java.util.Arrays; //导入方法依赖的package包/类
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;
}
}
}
}
示例11: checkRange
import java.util.Arrays; //导入方法依赖的package包/类
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;
}
}
}
}