1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import jsr166y.*; |
10 |
|
import static extra166y.Ops.*; |
11 |
|
import java.util.*; |
57 |
|
* subclass, prefixed FJO (object reference), FJD (double) and FJL |
58 |
|
* (long). |
59 |
|
*/ |
60 |
< |
static abstract class FJBase extends RecursiveAction { |
60 |
> |
abstract static class FJBase extends RecursiveAction { |
61 |
|
final AbstractParallelAnyArray pap; |
62 |
|
final int lo; |
63 |
|
final int hi; |
677 |
|
} |
678 |
|
} |
679 |
|
|
680 |
< |
void atLeaf(int l, int h) { |
680 |
> |
void atLeaf(int l, int h) { |
681 |
|
if (pap.hasFilter()) |
682 |
|
filteredAtLeaf(l, h); |
683 |
|
else { |
690 |
|
} |
691 |
|
} |
692 |
|
|
693 |
< |
void filteredAtLeaf(int l, int h) { |
693 |
> |
void filteredAtLeaf(int l, int h) { |
694 |
|
for (int i = l; i < h; ++i) { |
695 |
|
if (pap.isSelected(i)) { |
696 |
|
Object x = pap.oget(i); |
773 |
|
} |
774 |
|
} |
775 |
|
|
776 |
< |
void filteredAtLeaf(int l, int h) { |
776 |
> |
void filteredAtLeaf(int l, int h) { |
777 |
|
for (int i = l; i < h; ++i) { |
778 |
|
if (pap.isSelected(i)) { |
779 |
|
double x = pap.dget(i); |
844 |
|
} |
845 |
|
} |
846 |
|
|
847 |
< |
void atLeaf(int l, int h) { |
847 |
> |
void atLeaf(int l, int h) { |
848 |
|
if (pap.hasFilter()) |
849 |
|
filteredAtLeaf(l, h); |
850 |
|
else { |
858 |
|
} |
859 |
|
} |
860 |
|
|
861 |
< |
void filteredAtLeaf(int l, int h) { |
861 |
> |
void filteredAtLeaf(int l, int h) { |
862 |
|
for (int i = l; i < h; ++i) { |
863 |
|
if (pap.isSelected(i)) { |
864 |
|
long x = pap.lget(i); |
907 |
|
* Base for cancellable search tasks. Same idea as FJBase |
908 |
|
* but cancels tasks when result nonnegative. |
909 |
|
*/ |
910 |
< |
static abstract class FJSearchBase extends RecursiveAction { |
910 |
> |
abstract static class FJSearchBase extends RecursiveAction { |
911 |
|
final AbstractParallelAnyArray pap; |
912 |
|
final int lo; |
913 |
|
final int hi; |
1135 |
|
} |
1136 |
|
} |
1137 |
|
|
1138 |
< |
static abstract class FJSelectAllDriver extends RecursiveAction { |
1138 |
> |
abstract static class FJSelectAllDriver extends RecursiveAction { |
1139 |
|
final int[] indices; |
1140 |
|
final AbstractParallelAnyArray pap; |
1141 |
|
final int initialOffset; |
1575 |
|
} |
1576 |
|
|
1577 |
|
/** |
1578 |
< |
* Return new array holding all elements. |
1578 |
> |
* Returns new array holding all elements. |
1579 |
|
*/ |
1580 |
|
Object[] uniqueObjects(int size) { |
1581 |
|
Object[] src = pap.ogetArray(); |
1888 |
|
} |
1889 |
|
|
1890 |
|
/** |
1891 |
< |
* Perform merging for FJSorter. If big enough, splits Left |
1891 |
> |
* Performs merging for FJSorter. If big enough, splits Left |
1892 |
|
* partition in half; finds the greatest point in Right partition |
1893 |
|
* less than the beginning of the second half of Left via binary |
1894 |
|
* search; and then, in parallel, merges left half of Left with |
2462 |
|
* |
2463 |
|
* This class maintains only the basic control logic. Subclasses |
2464 |
|
* maintain the "in" and "out" fields, and *Ops classes perform |
2465 |
< |
* computations |
2465 |
> |
* computations. |
2466 |
|
*/ |
2467 |
< |
static abstract class FJScan extends ForkJoinTask<Void> { |
2467 |
> |
abstract static class FJScan extends ForkJoinTask<Void> { |
2468 |
|
static final short CUMULATE = (short)1; |
2469 |
|
static final short SUMMED = (short)2; |
2470 |
|
static final short FINISHED = (short)4; |
2633 |
|
/** |
2634 |
|
* Computational operations for FJScan |
2635 |
|
*/ |
2636 |
< |
static abstract class FJScanOp { |
2636 |
> |
abstract static class FJScanOp { |
2637 |
|
final int threshold; |
2638 |
|
final int origin; |
2639 |
|
final int fence; |
2650 |
|
abstract FJScan newSubtask(FJScan parent, int lo, int hi); |
2651 |
|
} |
2652 |
|
|
2653 |
< |
static abstract class FJOScanOp extends FJScanOp { |
2653 |
> |
abstract static class FJOScanOp extends FJScanOp { |
2654 |
|
final Object[] array; |
2655 |
|
final Reducer reducer; |
2656 |
|
final Object base; |
2740 |
|
} |
2741 |
|
} |
2742 |
|
|
2743 |
< |
static abstract class FJDScanOp extends FJScanOp { |
2743 |
> |
abstract static class FJDScanOp extends FJScanOp { |
2744 |
|
final double[] array; |
2745 |
|
final DoubleReducer reducer; |
2746 |
|
final double base; |
2830 |
|
} |
2831 |
|
} |
2832 |
|
|
2833 |
< |
static abstract class FJLScanOp extends FJScanOp { |
2833 |
> |
abstract static class FJLScanOp extends FJScanOp { |
2834 |
|
final long[] array; |
2835 |
|
final LongReducer reducer; |
2836 |
|
final long base; |
2922 |
|
|
2923 |
|
// specialized versions for plus |
2924 |
|
|
2925 |
< |
static abstract class FJDScanPlusOp extends FJScanOp { |
2925 |
> |
abstract static class FJDScanPlusOp extends FJScanOp { |
2926 |
|
final double[] array; |
2927 |
|
FJDScanPlusOp(AbstractParallelAnyArray.DPap pap) { |
2928 |
|
super(pap); |
3004 |
|
} |
3005 |
|
} |
3006 |
|
|
3007 |
< |
static abstract class FJLScanPlusOp extends FJScanOp { |
3007 |
> |
abstract static class FJLScanPlusOp extends FJScanOp { |
3008 |
|
final long[] array; |
3009 |
|
FJLScanPlusOp(AbstractParallelAnyArray.LPap pap) { |
3010 |
|
super(pap); |