5 |
|
*/ |
6 |
|
|
7 |
|
package java.util; |
8 |
< |
import java.util.concurrent.ForkJoinPool; |
8 |
> |
|
9 |
|
import java.util.concurrent.CountedCompleter; |
10 |
+ |
import java.util.concurrent.ForkJoinPool; |
11 |
|
import java.util.function.BinaryOperator; |
12 |
+ |
import java.util.function.DoubleBinaryOperator; |
13 |
|
import java.util.function.IntBinaryOperator; |
14 |
|
import java.util.function.LongBinaryOperator; |
13 |
– |
import java.util.function.DoubleBinaryOperator; |
15 |
|
|
16 |
|
/** |
17 |
|
* ForkJoin tasks to perform Arrays.parallelPrefix operations. |
20 |
|
* @since 1.8 |
21 |
|
*/ |
22 |
|
class ArrayPrefixHelpers { |
23 |
< |
private ArrayPrefixHelpers() {}; // non-instantiable |
23 |
> |
private ArrayPrefixHelpers() {} // non-instantiable |
24 |
|
|
25 |
|
/* |
26 |
|
* Parallel prefix (aka cumulate, scan) task classes |
118 |
|
int mid = (l + h) >>> 1; |
119 |
|
f = rt = t.right = |
120 |
|
new CumulateTask<T>(t, fn, a, org, fnc, th, mid, h); |
121 |
< |
t = lt = t.left = |
121 |
> |
t = lt = t.left = |
122 |
|
new CumulateTask<T>(t, fn, a, org, fnc, th, l, mid); |
123 |
|
} |
124 |
|
else { // possibly refork |
270 |
|
int mid = (l + h) >>> 1; |
271 |
|
f = rt = t.right = |
272 |
|
new LongCumulateTask(t, fn, a, org, fnc, th, mid, h); |
273 |
< |
t = lt = t.left = |
273 |
> |
t = lt = t.left = |
274 |
|
new LongCumulateTask(t, fn, a, org, fnc, th, l, mid); |
275 |
|
} |
276 |
|
else { // possibly refork |
384 |
|
|
385 |
|
/** Root task constructor */ |
386 |
|
public DoubleCumulateTask(DoubleCumulateTask parent, |
387 |
< |
DoubleBinaryOperator function, |
388 |
< |
double[] array, int lo, int hi) { |
387 |
> |
DoubleBinaryOperator function, |
388 |
> |
double[] array, int lo, int hi) { |
389 |
|
super(parent); |
390 |
|
this.function = function; this.array = array; |
391 |
|
this.lo = this.origin = lo; this.hi = this.fence = hi; |
397 |
|
|
398 |
|
/** Subtask constructor */ |
399 |
|
DoubleCumulateTask(DoubleCumulateTask parent, DoubleBinaryOperator function, |
400 |
< |
double[] array, int origin, int fence, int threshold, |
401 |
< |
int lo, int hi) { |
400 |
> |
double[] array, int origin, int fence, int threshold, |
401 |
> |
int lo, int hi) { |
402 |
|
super(parent); |
403 |
|
this.function = function; this.array = array; |
404 |
|
this.origin = origin; this.fence = fence; |
420 |
|
int mid = (l + h) >>> 1; |
421 |
|
f = rt = t.right = |
422 |
|
new DoubleCumulateTask(t, fn, a, org, fnc, th, mid, h); |
423 |
< |
t = lt = t.left = |
423 |
> |
t = lt = t.left = |
424 |
|
new DoubleCumulateTask(t, fn, a, org, fnc, th, l, mid); |
425 |
|
} |
426 |
|
else { // possibly refork |
534 |
|
|
535 |
|
/** Root task constructor */ |
536 |
|
public IntCumulateTask(IntCumulateTask parent, |
537 |
< |
IntBinaryOperator function, |
538 |
< |
int[] array, int lo, int hi) { |
537 |
> |
IntBinaryOperator function, |
538 |
> |
int[] array, int lo, int hi) { |
539 |
|
super(parent); |
540 |
|
this.function = function; this.array = array; |
541 |
|
this.lo = this.origin = lo; this.hi = this.fence = hi; |
547 |
|
|
548 |
|
/** Subtask constructor */ |
549 |
|
IntCumulateTask(IntCumulateTask parent, IntBinaryOperator function, |
550 |
< |
int[] array, int origin, int fence, int threshold, |
551 |
< |
int lo, int hi) { |
550 |
> |
int[] array, int origin, int fence, int threshold, |
551 |
> |
int lo, int hi) { |
552 |
|
super(parent); |
553 |
|
this.function = function; this.array = array; |
554 |
|
this.origin = origin; this.fence = fence; |
570 |
|
int mid = (l + h) >>> 1; |
571 |
|
f = rt = t.right = |
572 |
|
new IntCumulateTask(t, fn, a, org, fnc, th, mid, h); |
573 |
< |
t = lt = t.left = |
573 |
> |
t = lt = t.left = |
574 |
|
new IntCumulateTask(t, fn, a, org, fnc, th, l, mid); |
575 |
|
} |
576 |
|
else { // possibly refork |
674 |
|
} |
675 |
|
private static final long serialVersionUID = 3731755594596840961L; |
676 |
|
} |
676 |
– |
|
677 |
|
} |