本文整理匯總了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;
}
}
}
}