Modifier and Type | Method and Description |
---|---|
static void |
parallelPrefix(double[] array,
DoubleBinaryOperator op)
Cumulates, in parallel, each element of the given array in place,
using the supplied function.
|
static void |
parallelPrefix(double[] array,
int fromIndex,
int toIndex,
DoubleBinaryOperator op)
Performs
parallelPrefix(double[], DoubleBinaryOperator)
for the given subrange of the array. |
static void |
parallelPrefix(int[] array,
IntBinaryOperator op)
Cumulates, in parallel, each element of the given array in place,
using the supplied function.
|
static void |
parallelPrefix(int[] array,
int fromIndex,
int toIndex,
IntBinaryOperator op)
Performs
parallelPrefix(int[], IntBinaryOperator)
for the given subrange of the array. |
static void |
parallelPrefix(long[] array,
int fromIndex,
int toIndex,
LongBinaryOperator op)
Performs
parallelPrefix(long[], LongBinaryOperator)
for the given subrange of the array. |
static void |
parallelPrefix(long[] array,
LongBinaryOperator op)
Cumulates, in parallel, each element of the given array in place,
using the supplied function.
|
static <T> void |
parallelPrefix(T[] array,
BinaryOperator<T> op)
Cumulates, in parallel, each element of the given array in place,
using the supplied function.
|
static <T> void |
parallelPrefix(T[] array,
int fromIndex,
int toIndex,
BinaryOperator<T> op)
Performs
parallelPrefix(Object[], BinaryOperator)
for the given subrange of the array. |
static void |
parallelSetAll(double[] array,
IntToDoubleFunction generator)
Set all elements of the specified array, in parallel, using the
provided generator function to compute each element.
|
static void |
parallelSetAll(int[] array,
IntUnaryOperator generator)
Set all elements of the specified array, in parallel, using the
provided generator function to compute each element.
|
static void |
parallelSetAll(long[] array,
IntToLongFunction generator)
Set all elements of the specified array, in parallel, using the
provided generator function to compute each element.
|
static <T> void |
parallelSetAll(T[] array,
IntFunction<? extends T> generator)
Set all elements of the specified array, in parallel, using the
provided generator function to compute each element.
|
static void |
parallelSort(byte[] a)
Sorts the specified array into ascending numerical order.
|
static void |
parallelSort(byte[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the array into ascending numerical order.
|
static void |
parallelSort(char[] a)
Sorts the specified array into ascending numerical order.
|
static void |
parallelSort(char[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the array into ascending numerical order.
|
static void |
parallelSort(double[] a)
Sorts the specified array into ascending numerical order.
|
static void |
parallelSort(double[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the array into ascending numerical order.
|
static void |
parallelSort(float[] a)
Sorts the specified array into ascending numerical order.
|
static void |
parallelSort(float[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the array into ascending numerical order.
|
static void |
parallelSort(int[] a)
Sorts the specified array into ascending numerical order.
|
static void |
parallelSort(int[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the array into ascending numerical order.
|
static void |
parallelSort(long[] a)
Sorts the specified array into ascending numerical order.
|
static void |
parallelSort(long[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the array into ascending numerical order.
|
static void |
parallelSort(short[] a)
Sorts the specified array into ascending numerical order.
|
static void |
parallelSort(short[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the array into ascending numerical order.
|
static <T extends Comparable<? super T>> |
parallelSort(T[] a)
Sorts the specified array of objects into ascending order, according
to the natural ordering of its elements.
|
static <T> void |
parallelSort(T[] a,
Comparator<? super T> cmp)
Sorts the specified array of objects according to the order induced by
the specified comparator.
|
static <T extends Comparable<? super T>> |
parallelSort(T[] a,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array of objects into
ascending order, according to the
natural ordering of its
elements.
|
static <T> void |
parallelSort(T[] a,
int fromIndex,
int toIndex,
Comparator<? super T> cmp)
Sorts the specified range of the specified array of objects according
to the order induced by the specified comparator.
|
static void |
setAll(double[] array,
IntToDoubleFunction generator)
Set all elements of the specified array, using the provided
generator function to compute each element.
|
static void |
setAll(int[] array,
IntUnaryOperator generator)
Set all elements of the specified array, using the provided
generator function to compute each element.
|
static void |
setAll(long[] array,
IntToLongFunction generator)
Set all elements of the specified array, using the provided
generator function to compute each element.
|
static <T> void |
setAll(T[] array,
IntFunction<? extends T> generator)
Set all elements of the specified array, using the provided
generator function to compute each element.
|
static Spliterator.OfDouble |
spliterator(double[] array)
Returns a
Spliterator.OfDouble covering all of the specified
array. |
static Spliterator.OfDouble |
spliterator(double[] array,
int startInclusive,
int endExclusive)
Returns a
Spliterator.OfDouble covering the specified range of
the specified array. |
static Spliterator.OfInt |
spliterator(int[] array)
Returns a
Spliterator.OfInt covering all of the specified array. |
static Spliterator.OfInt |
spliterator(int[] array,
int startInclusive,
int endExclusive)
Returns a
Spliterator.OfInt covering the specified range of the
specified array. |
static Spliterator.OfLong |
spliterator(long[] array)
Returns a
Spliterator.OfLong covering all of the specified array. |
static Spliterator.OfLong |
spliterator(long[] array,
int startInclusive,
int endExclusive)
Returns a
Spliterator.OfLong covering the specified range of the
specified array. |
static <T> Spliterator<T> |
spliterator(T[] array)
Returns a
Spliterator covering all of the specified array. |
static <T> Spliterator<T> |
spliterator(T[] array,
int startInclusive,
int endExclusive)
Returns a
Spliterator covering the specified range of the
specified array. |
static DoubleStream |
stream(double[] array)
Returns a sequential
DoubleStream with the specified array as its
source. |
static DoubleStream |
stream(double[] array,
int startInclusive,
int endExclusive)
Returns a sequential
DoubleStream with the specified range of the
specified array as its source. |
static IntStream |
stream(int[] array)
Returns a sequential
IntStream with the specified array as its
source. |
static IntStream |
stream(int[] array,
int startInclusive,
int endExclusive)
Returns a sequential
IntStream with the specified range of the
specified array as its source. |
static LongStream |
stream(long[] array)
Returns a sequential
LongStream with the specified array as its
source. |
static LongStream |
stream(long[] array,
int startInclusive,
int endExclusive)
Returns a sequential
LongStream with the specified range of the
specified array as its source. |
static <T> Stream<T> |
stream(T[] array)
Returns a sequential
Stream with the specified array as its
source. |
static <T> Stream<T> |
stream(T[] array,
int startInclusive,
int endExclusive)
Returns a sequential
Stream with the specified range of the
specified array as its source. |
public static <T> Spliterator<T> spliterator(T[] array)
Spliterator
covering all of the specified array.
The spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, Spliterator.ORDERED
, and
Spliterator.IMMUTABLE
.
T
- type of elementsarray
- the array, assumed to be unmodified during usepublic static <T> Spliterator<T> spliterator(T[] array, int startInclusive, int endExclusive)
Spliterator
covering the specified range of the
specified array.
The spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, Spliterator.ORDERED
, and
Spliterator.IMMUTABLE
.
T
- type of elementsarray
- the array, assumed to be unmodified during usestartInclusive
- the first index to cover, inclusiveendExclusive
- index immediately past the last index to coverArrayIndexOutOfBoundsException
- if startInclusive
is
negative, endExclusive
is less than
startInclusive
, or endExclusive
is greater than
the array sizepublic static Spliterator.OfInt spliterator(int[] array)
Spliterator.OfInt
covering all of the specified array.
The spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, Spliterator.ORDERED
, and
Spliterator.IMMUTABLE
.
array
- the array, assumed to be unmodified during usepublic static Spliterator.OfInt spliterator(int[] array, int startInclusive, int endExclusive)
Spliterator.OfInt
covering the specified range of the
specified array.
The spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, Spliterator.ORDERED
, and
Spliterator.IMMUTABLE
.
array
- the array, assumed to be unmodified during usestartInclusive
- the first index to cover, inclusiveendExclusive
- index immediately past the last index to coverArrayIndexOutOfBoundsException
- if startInclusive
is
negative, endExclusive
is less than
startInclusive
, or endExclusive
is greater than
the array sizepublic static Spliterator.OfLong spliterator(long[] array)
Spliterator.OfLong
covering all of the specified array.
The spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, Spliterator.ORDERED
, and
Spliterator.IMMUTABLE
.
array
- the array, assumed to be unmodified during usepublic static Spliterator.OfLong spliterator(long[] array, int startInclusive, int endExclusive)
Spliterator.OfLong
covering the specified range of the
specified array.
The spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, Spliterator.ORDERED
, and
Spliterator.IMMUTABLE
.
array
- the array, assumed to be unmodified during usestartInclusive
- the first index to cover, inclusiveendExclusive
- index immediately past the last index to coverArrayIndexOutOfBoundsException
- if startInclusive
is
negative, endExclusive
is less than
startInclusive
, or endExclusive
is greater than
the array sizepublic static Spliterator.OfDouble spliterator(double[] array)
Spliterator.OfDouble
covering all of the specified
array.
The spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, Spliterator.ORDERED
, and
Spliterator.IMMUTABLE
.
array
- the array, assumed to be unmodified during usepublic static Spliterator.OfDouble spliterator(double[] array, int startInclusive, int endExclusive)
Spliterator.OfDouble
covering the specified range of
the specified array.
The spliterator reports Spliterator.SIZED
,
Spliterator.SUBSIZED
, Spliterator.ORDERED
, and
Spliterator.IMMUTABLE
.
array
- the array, assumed to be unmodified during usestartInclusive
- the first index to cover, inclusiveendExclusive
- index immediately past the last index to coverArrayIndexOutOfBoundsException
- if startInclusive
is
negative, endExclusive
is less than
startInclusive
, or endExclusive
is greater than
the array sizepublic static <T> Stream<T> stream(T[] array)
Stream
with the specified array as its
source.T
- The type of the array elementsarray
- The array, assumed to be unmodified during useStream
for the arraypublic static <T> Stream<T> stream(T[] array, int startInclusive, int endExclusive)
Stream
with the specified range of the
specified array as its source.T
- the type of the array elementsarray
- the array, assumed to be unmodified during usestartInclusive
- the first index to cover, inclusiveendExclusive
- index immediately past the last index to coverStream
for the array rangeArrayIndexOutOfBoundsException
- if startInclusive
is
negative, endExclusive
is less than
startInclusive
, or endExclusive
is greater than
the array sizepublic static IntStream stream(int[] array)
IntStream
with the specified array as its
source.array
- the array, assumed to be unmodified during useIntStream
for the arraypublic static IntStream stream(int[] array, int startInclusive, int endExclusive)
IntStream
with the specified range of the
specified array as its source.array
- the array, assumed to be unmodified during usestartInclusive
- the first index to cover, inclusiveendExclusive
- index immediately past the last index to coverIntStream
for the array rangeArrayIndexOutOfBoundsException
- if startInclusive
is
negative, endExclusive
is less than
startInclusive
, or endExclusive
is greater than
the array sizepublic static LongStream stream(long[] array)
LongStream
with the specified array as its
source.array
- the array, assumed to be unmodified during useLongStream
for the arraypublic static LongStream stream(long[] array, int startInclusive, int endExclusive)
LongStream
with the specified range of the
specified array as its source.array
- the array, assumed to be unmodified during usestartInclusive
- the first index to cover, inclusiveendExclusive
- index immediately past the last index to coverLongStream
for the array rangeArrayIndexOutOfBoundsException
- if startInclusive
is
negative, endExclusive
is less than
startInclusive
, or endExclusive
is greater than
the array sizepublic static DoubleStream stream(double[] array)
DoubleStream
with the specified array as its
source.array
- the array, assumed to be unmodified during useDoubleStream
for the arraypublic static DoubleStream stream(double[] array, int startInclusive, int endExclusive)
DoubleStream
with the specified range of the
specified array as its source.array
- the array, assumed to be unmodified during usestartInclusive
- the first index to cover, inclusiveendExclusive
- index immediately past the last index to coverDoubleStream
for the array rangeArrayIndexOutOfBoundsException
- if startInclusive
is
negative, endExclusive
is less than
startInclusive
, or endExclusive
is greater than
the array sizepublic static void parallelSort(byte[] a)
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
a
- the array to be sortedpublic static void parallelSort(byte[] a, int fromIndex, int toIndex)
fromIndex
,
inclusive, to the index toIndex
, exclusive. If
fromIndex == toIndex
, the range to be sorted is empty.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
a
- the array to be sortedfromIndex
- the index of the first element, inclusive, to be sortedtoIndex
- the index of the last element, exclusive, to be sortedIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > a.length
public static void parallelSort(char[] a)
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
a
- the array to be sortedpublic static void parallelSort(char[] a, int fromIndex, int toIndex)
fromIndex
,
inclusive, to the index toIndex
, exclusive. If
fromIndex == toIndex
, the range to be sorted is empty.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
a
- the array to be sortedfromIndex
- the index of the first element, inclusive, to be sortedtoIndex
- the index of the last element, exclusive, to be sortedIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > a.length
public static void parallelSort(short[] a)
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
a
- the array to be sortedpublic static void parallelSort(short[] a, int fromIndex, int toIndex)
fromIndex
,
inclusive, to the index toIndex
, exclusive. If
fromIndex == toIndex
, the range to be sorted is empty.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
a
- the array to be sortedfromIndex
- the index of the first element, inclusive, to be sortedtoIndex
- the index of the last element, exclusive, to be sortedIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > a.length
public static void parallelSort(int[] a)
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
a
- the array to be sortedpublic static void parallelSort(int[] a, int fromIndex, int toIndex)
fromIndex
,
inclusive, to the index toIndex
, exclusive. If
fromIndex == toIndex
, the range to be sorted is empty.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
a
- the array to be sortedfromIndex
- the index of the first element, inclusive, to be sortedtoIndex
- the index of the last element, exclusive, to be sortedIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > a.length
public static void parallelSort(long[] a)
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
a
- the array to be sortedpublic static void parallelSort(long[] a, int fromIndex, int toIndex)
fromIndex
,
inclusive, to the index toIndex
, exclusive. If
fromIndex == toIndex
, the range to be sorted is empty.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
a
- the array to be sortedfromIndex
- the index of the first element, inclusive, to be sortedtoIndex
- the index of the last element, exclusive, to be sortedIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > a.length
public static void parallelSort(float[] a)
The <
relation does not provide a total order on all float
values: -0.0f == 0.0f
is true
and a Float.NaN
value compares neither less than, greater than, nor equal to any value,
even itself. This method uses the total order imposed by the method
Float.compareTo(java.lang.Float)
: -0.0f
is treated as less than value
0.0f
and Float.NaN
is considered greater than any
other value and all Float.NaN
values are considered equal.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
a
- the array to be sortedpublic static void parallelSort(float[] a, int fromIndex, int toIndex)
fromIndex
,
inclusive, to the index toIndex
, exclusive. If
fromIndex == toIndex
, the range to be sorted is empty.
The <
relation does not provide a total order on all float
values: -0.0f == 0.0f
is true
and a Float.NaN
value compares neither less than, greater than, nor equal to any value,
even itself. This method uses the total order imposed by the method
Float.compareTo(java.lang.Float)
: -0.0f
is treated as less than value
0.0f
and Float.NaN
is considered greater than any
other value and all Float.NaN
values are considered equal.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
a
- the array to be sortedfromIndex
- the index of the first element, inclusive, to be sortedtoIndex
- the index of the last element, exclusive, to be sortedIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > a.length
public static void parallelSort(double[] a)
The <
relation does not provide a total order on all double
values: -0.0d == 0.0d
is true
and a Double.NaN
value compares neither less than, greater than, nor equal to any value,
even itself. This method uses the total order imposed by the method
Double.compareTo(java.lang.Double)
: -0.0d
is treated as less than value
0.0d
and Double.NaN
is considered greater than any
other value and all Double.NaN
values are considered equal.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
a
- the array to be sortedpublic static void parallelSort(double[] a, int fromIndex, int toIndex)
fromIndex
,
inclusive, to the index toIndex
, exclusive. If
fromIndex == toIndex
, the range to be sorted is empty.
The <
relation does not provide a total order on all double
values: -0.0d == 0.0d
is true
and a Double.NaN
value compares neither less than, greater than, nor equal to any value,
even itself. This method uses the total order imposed by the method
Double.compareTo(java.lang.Double)
: -0.0d
is treated as less than value
0.0d
and Double.NaN
is considered greater than any
other value and all Double.NaN
values are considered equal.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
a
- the array to be sortedfromIndex
- the index of the first element, inclusive, to be sortedtoIndex
- the index of the last element, exclusive, to be sortedIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > a.length
public static <T extends Comparable<? super T>> void parallelSort(T[] a)
Comparable
interface. Furthermore, all elements in the array must be
mutually comparable (that is, e1.compareTo(e2)
must
not throw a ClassCastException
for any elements e1
and e2
in the array).
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
T
- the class of the objects to be sorteda
- the array to be sortedClassCastException
- if the array contains elements that are not
mutually comparable (for example, strings and integers)IllegalArgumentException
- (optional) if the natural
ordering of the array elements is found to violate the
Comparable
contractpublic static <T extends Comparable<? super T>> void parallelSort(T[] a, int fromIndex, int toIndex)
fromIndex
, inclusive, to index toIndex
, exclusive.
(If fromIndex==toIndex
, the range to be sorted is empty.) All
elements in this range must implement the Comparable
interface. Furthermore, all elements in this range must be mutually
comparable (that is, e1.compareTo(e2)
must not throw a
ClassCastException
for any elements e1
and
e2
in the array).
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
T
- the class of the objects to be sorteda
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be
sortedtoIndex
- the index of the last element (exclusive) to be sortedIllegalArgumentException
- if fromIndex > toIndex
or
(optional) if the natural ordering of the array elements is
found to violate the Comparable
contractArrayIndexOutOfBoundsException
- if fromIndex < 0
or
toIndex > a.length
ClassCastException
- if the array contains elements that are
not mutually comparable (for example, strings and
integers).public static <T> void parallelSort(T[] a, Comparator<? super T> cmp)
c.compare(e1, e2)
must not throw a ClassCastException
for any elements e1
and e2
in the array).
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a
working space no greater than the size of the original array. The
ForkJoin common pool
is used to
execute any parallel tasks.
T
- the class of the objects to be sorteda
- the array to be sortedcmp
- the comparator to determine the order of the array. A
null
value indicates that the elements'
natural ordering should be used.ClassCastException
- if the array contains elements that are
not mutually comparable using the specified comparatorIllegalArgumentException
- (optional) if the comparator is
found to violate the Comparator
contractpublic static <T> void parallelSort(T[] a, int fromIndex, int toIndex, Comparator<? super T> cmp)
fromIndex
, inclusive, to index
toIndex
, exclusive. (If fromIndex==toIndex
, the
range to be sorted is empty.) All elements in the range must be
mutually comparable by the specified comparator (that is,
c.compare(e1, e2)
must not throw a ClassCastException
for any elements e1
and e2
in the range).
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
Implementation Note:
The sorting algorithm is a parallel sort-merge that breaks the
array into sub-arrays that are themselves sorted and then merged. When
the sub-array length reaches a minimum granularity, the sub-array is
sorted using the appropriate Arrays.sort
method. If the length of the specified array is less than the minimum
granularity, then it is sorted using the appropriate Arrays.sort
method. The algorithm requires a working
space no greater than the size of the specified range of the original
array. The ForkJoin common pool
is
used to execute any parallel tasks.
T
- the class of the objects to be sorteda
- the array to be sortedfromIndex
- the index of the first element (inclusive) to be
sortedtoIndex
- the index of the last element (exclusive) to be sortedcmp
- the comparator to determine the order of the array. A
null
value indicates that the elements'
natural ordering should be used.IllegalArgumentException
- if fromIndex > toIndex
or
(optional) if the natural ordering of the array elements is
found to violate the Comparable
contractArrayIndexOutOfBoundsException
- if fromIndex < 0
or
toIndex > a.length
ClassCastException
- if the array contains elements that are
not mutually comparable (for example, strings and
integers).public static <T> void setAll(T[] array, IntFunction<? extends T> generator)
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
API Note:
Setting a subrange of an array, using a generator function to compute
each element, can be written as follows:
IntStreams.range(startInclusive, endExclusive)
.forEach(i -> array[i] = generator.apply(i));
T
- type of elements of the arrayarray
- array to be initializedgenerator
- a function accepting an index and producing the desired
value for that positionNullPointerException
- if the generator is nullpublic static <T> void parallelSetAll(T[] array, IntFunction<? extends T> generator)
If the generator function throws an exception, an unchecked exception
is thrown from parallelSetAll
and the array is left in an
indeterminate state.
API Note:
Setting a subrange of an array, in parallel, using a generator function
to compute each element, can be written as follows:
IntStreams.range(startInclusive, endExclusive)
.parallel()
.forEach(i -> array[i] = generator.apply(i));
T
- type of elements of the arrayarray
- array to be initializedgenerator
- a function accepting an index and producing the desired
value for that positionNullPointerException
- if the generator is nullpublic static void setAll(int[] array, IntUnaryOperator generator)
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
API Note:
Setting a subrange of an array, using a generator function to compute
each element, can be written as follows:
IntStreams.range(startInclusive, endExclusive)
.forEach(i -> array[i] = generator.applyAsInt(i));
array
- array to be initializedgenerator
- a function accepting an index and producing the desired
value for that positionNullPointerException
- if the generator is nullpublic static void parallelSetAll(int[] array, IntUnaryOperator generator)
If the generator function throws an exception, an unchecked exception
is thrown from parallelSetAll
and the array is left in an
indeterminate state.
API Note:
Setting a subrange of an array, in parallel, using a generator function
to compute each element, can be written as follows:
IntStreams.range(startInclusive, endExclusive)
.parallel()
.forEach(i -> array[i] = generator.applyAsInt(i));
array
- array to be initializedgenerator
- a function accepting an index and producing the desired
value for that positionNullPointerException
- if the generator is nullpublic static void setAll(long[] array, IntToLongFunction generator)
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
API Note:
Setting a subrange of an array, using a generator function to compute
each element, can be written as follows:
IntStreams.range(startInclusive, endExclusive)
.forEach(i -> array[i] = generator.applyAsLong(i));
array
- array to be initializedgenerator
- a function accepting an index and producing the desired
value for that positionNullPointerException
- if the generator is nullpublic static void parallelSetAll(long[] array, IntToLongFunction generator)
If the generator function throws an exception, an unchecked exception
is thrown from parallelSetAll
and the array is left in an
indeterminate state.
API Note:
Setting a subrange of an array, in parallel, using a generator function
to compute each element, can be written as follows:
IntStreams.range(startInclusive, endExclusive)
.parallel()
.forEach(i -> array[i] = generator.applyAsLong(i));
array
- array to be initializedgenerator
- a function accepting an index and producing the desired
value for that positionNullPointerException
- if the generator is nullpublic static void setAll(double[] array, IntToDoubleFunction generator)
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
API Note:
Setting a subrange of an array, using a generator function to compute
each element, can be written as follows:
IntStreams.range(startInclusive, endExclusive)
.forEach(i -> array[i] = generator.applyAsDouble(i));
array
- array to be initializedgenerator
- a function accepting an index and producing the desired
value for that positionNullPointerException
- if the generator is nullpublic static void parallelSetAll(double[] array, IntToDoubleFunction generator)
If the generator function throws an exception, an unchecked exception
is thrown from parallelSetAll
and the array is left in an
indeterminate state.
API Note:
Setting a subrange of an array, in parallel, using a generator function
to compute each element, can be written as follows:
IntStreams.range(startInclusive, endExclusive)
.parallel()
.forEach(i -> array[i] = generator.applyAsDouble(i));
array
- array to be initializedgenerator
- a function accepting an index and producing the desired
value for that positionNullPointerException
- if the generator is nullpublic static <T> void parallelPrefix(T[] array, BinaryOperator<T> op)
[2, 1, 0, 3]
and the operation performs addition,
then upon return the array holds [2, 3, 3, 6]
.
Parallel prefix computation is usually more efficient than
sequential loops for large arrays.T
- the class of the objects in the arrayarray
- the array, which is modified in-place by this methodop
- a side-effect-free, associative function to perform the
cumulationNullPointerException
- if the specified array or function is nullpublic static <T> void parallelPrefix(T[] array, int fromIndex, int toIndex, BinaryOperator<T> op)
parallelPrefix(Object[], BinaryOperator)
for the given subrange of the array.T
- the class of the objects in the arrayarray
- the arrayfromIndex
- the index of the first element, inclusivetoIndex
- the index of the last element, exclusiveop
- a side-effect-free, associative function to perform the
cumulationIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > array.length
NullPointerException
- if the specified array or function is nullpublic static void parallelPrefix(long[] array, LongBinaryOperator op)
[2, 1, 0, 3]
and the operation performs addition,
then upon return the array holds [2, 3, 3, 6]
.
Parallel prefix computation is usually more efficient than
sequential loops for large arrays.array
- the array, which is modified in-place by this methodop
- a side-effect-free, associative function to perform the
cumulationNullPointerException
- if the specified array or function is nullpublic static void parallelPrefix(long[] array, int fromIndex, int toIndex, LongBinaryOperator op)
parallelPrefix(long[], LongBinaryOperator)
for the given subrange of the array.array
- the arrayfromIndex
- the index of the first element, inclusivetoIndex
- the index of the last element, exclusiveop
- a side-effect-free, associative function to perform the
cumulationIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > array.length
NullPointerException
- if the specified array or function is nullpublic static void parallelPrefix(double[] array, DoubleBinaryOperator op)
[2.0, 1.0, 0.0, 3.0]
and the operation performs addition,
then upon return the array holds [2.0, 3.0, 3.0, 6.0]
.
Parallel prefix computation is usually more efficient than
sequential loops for large arrays.
Because floating-point operations may not be strictly associative, the returned result may not be identical to the value that would be obtained if the operation was performed sequentially.
array
- the array, which is modified in-place by this methodop
- a side-effect-free function to perform the cumulationNullPointerException
- if the specified array or function is nullpublic static void parallelPrefix(double[] array, int fromIndex, int toIndex, DoubleBinaryOperator op)
parallelPrefix(double[], DoubleBinaryOperator)
for the given subrange of the array.array
- the arrayfromIndex
- the index of the first element, inclusivetoIndex
- the index of the last element, exclusiveop
- a side-effect-free, associative function to perform the
cumulationIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > array.length
NullPointerException
- if the specified array or function is nullpublic static void parallelPrefix(int[] array, IntBinaryOperator op)
[2, 1, 0, 3]
and the operation performs addition,
then upon return the array holds [2, 3, 3, 6]
.
Parallel prefix computation is usually more efficient than
sequential loops for large arrays.array
- the array, which is modified in-place by this methodop
- a side-effect-free, associative function to perform the
cumulationNullPointerException
- if the specified array or function is nullpublic static void parallelPrefix(int[] array, int fromIndex, int toIndex, IntBinaryOperator op)
parallelPrefix(int[], IntBinaryOperator)
for the given subrange of the array.array
- the arrayfromIndex
- the index of the first element, inclusivetoIndex
- the index of the last element, exclusiveop
- a side-effect-free, associative function to perform the
cumulationIllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0
or toIndex > array.length
NullPointerException
- if the specified array or function is nullCopyright © 2015. All rights reserved.