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; |
56 |
|
* subclass, prefixed FJO (object reference), FJD (double) and FJL |
57 |
|
* (long). |
58 |
|
*/ |
59 |
< |
static abstract class FJBase extends RecursiveAction { |
59 |
> |
abstract static class FJBase extends RecursiveAction { |
60 |
|
final AbstractParallelAnyArray pap; |
61 |
|
final int lo; |
62 |
|
final int hi; |
676 |
|
} |
677 |
|
} |
678 |
|
|
679 |
< |
void atLeaf(int l, int h) { |
679 |
> |
void atLeaf(int l, int h) { |
680 |
|
if (pap.hasFilter()) |
681 |
|
filteredAtLeaf(l, h); |
682 |
|
else { |
689 |
|
} |
690 |
|
} |
691 |
|
|
692 |
< |
void filteredAtLeaf(int l, int h) { |
692 |
> |
void filteredAtLeaf(int l, int h) { |
693 |
|
for (int i = l; i < h; ++i) { |
694 |
|
if (pap.isSelected(i)) { |
695 |
|
Object x = pap.oget(i); |
772 |
|
} |
773 |
|
} |
774 |
|
|
775 |
< |
void filteredAtLeaf(int l, int h) { |
775 |
> |
void filteredAtLeaf(int l, int h) { |
776 |
|
for (int i = l; i < h; ++i) { |
777 |
|
if (pap.isSelected(i)) { |
778 |
|
double x = pap.dget(i); |
843 |
|
} |
844 |
|
} |
845 |
|
|
846 |
< |
void atLeaf(int l, int h) { |
846 |
> |
void atLeaf(int l, int h) { |
847 |
|
if (pap.hasFilter()) |
848 |
|
filteredAtLeaf(l, h); |
849 |
|
else { |
857 |
|
} |
858 |
|
} |
859 |
|
|
860 |
< |
void filteredAtLeaf(int l, int h) { |
860 |
> |
void filteredAtLeaf(int l, int h) { |
861 |
|
for (int i = l; i < h; ++i) { |
862 |
|
if (pap.isSelected(i)) { |
863 |
|
long x = pap.lget(i); |
906 |
|
* Base for cancellable search tasks. Same idea as FJBase |
907 |
|
* but cancels tasks when result nonnegative. |
908 |
|
*/ |
909 |
< |
static abstract class FJSearchBase extends RecursiveAction { |
909 |
> |
abstract static class FJSearchBase extends RecursiveAction { |
910 |
|
final AbstractParallelAnyArray pap; |
911 |
|
final int lo; |
912 |
|
final int hi; |
1134 |
|
} |
1135 |
|
} |
1136 |
|
|
1137 |
< |
static abstract class FJSelectAllDriver extends RecursiveAction { |
1137 |
> |
abstract static class FJSelectAllDriver extends RecursiveAction { |
1138 |
|
final int[] indices; |
1139 |
|
final AbstractParallelAnyArray pap; |
1140 |
|
final int initialOffset; |
1574 |
|
} |
1575 |
|
|
1576 |
|
/** |
1577 |
< |
* Return new array holding all elements. |
1577 |
> |
* Returns new array holding all elements. |
1578 |
|
*/ |
1579 |
|
Object[] uniqueObjects(int size) { |
1580 |
|
Object[] src = pap.ogetArray(); |
1887 |
|
} |
1888 |
|
|
1889 |
|
/** |
1890 |
< |
* Perform merging for FJSorter. If big enough, splits Left |
1890 |
> |
* Performs merging for FJSorter. If big enough, splits Left |
1891 |
|
* partition in half; finds the greatest point in Right partition |
1892 |
|
* less than the beginning of the second half of Left via binary |
1893 |
|
* search; and then, in parallel, merges left half of Left with |
2463 |
|
* maintain the "in" and "out" fields, and *Ops classes perform |
2464 |
|
* computations |
2465 |
|
*/ |
2466 |
< |
static abstract class FJScan extends ForkJoinTask<Void> { |
2466 |
> |
abstract static class FJScan extends ForkJoinTask<Void> { |
2467 |
|
static final short CUMULATE = (short)1; |
2468 |
|
static final short SUMMED = (short)2; |
2469 |
|
static final short FINISHED = (short)4; |
2632 |
|
/** |
2633 |
|
* Computational operations for FJScan |
2634 |
|
*/ |
2635 |
< |
static abstract class FJScanOp { |
2635 |
> |
abstract static class FJScanOp { |
2636 |
|
final int threshold; |
2637 |
|
final int origin; |
2638 |
|
final int fence; |
2649 |
|
abstract FJScan newSubtask(FJScan parent, int lo, int hi); |
2650 |
|
} |
2651 |
|
|
2652 |
< |
static abstract class FJOScanOp extends FJScanOp { |
2652 |
> |
abstract static class FJOScanOp extends FJScanOp { |
2653 |
|
final Object[] array; |
2654 |
|
final Reducer reducer; |
2655 |
|
final Object base; |
2739 |
|
} |
2740 |
|
} |
2741 |
|
|
2742 |
< |
static abstract class FJDScanOp extends FJScanOp { |
2742 |
> |
abstract static class FJDScanOp extends FJScanOp { |
2743 |
|
final double[] array; |
2744 |
|
final DoubleReducer reducer; |
2745 |
|
final double base; |
2829 |
|
} |
2830 |
|
} |
2831 |
|
|
2832 |
< |
static abstract class FJLScanOp extends FJScanOp { |
2832 |
> |
abstract static class FJLScanOp extends FJScanOp { |
2833 |
|
final long[] array; |
2834 |
|
final LongReducer reducer; |
2835 |
|
final long base; |
2921 |
|
|
2922 |
|
// specialized versions for plus |
2923 |
|
|
2924 |
< |
static abstract class FJDScanPlusOp extends FJScanOp { |
2924 |
> |
abstract static class FJDScanPlusOp extends FJScanOp { |
2925 |
|
final double[] array; |
2926 |
|
FJDScanPlusOp(AbstractParallelAnyArray.DPap pap) { |
2927 |
|
super(pap); |
3003 |
|
} |
3004 |
|
} |
3005 |
|
|
3006 |
< |
static abstract class FJLScanPlusOp extends FJScanOp { |
3006 |
> |
abstract static class FJLScanPlusOp extends FJScanOp { |
3007 |
|
final long[] array; |
3008 |
|
FJLScanPlusOp(AbstractParallelAnyArray.LPap pap) { |
3009 |
|
super(pap); |