5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import jsr166y.*; |
10 |
|
import static extra166y.Ops.*; |
11 |
|
import java.util.*; |
133 |
|
*/ |
134 |
|
Object[] ogetArray() { return null; } |
135 |
|
double[] dgetArray() { return null; } |
136 |
< |
long[] lgetArray() { return null; } |
136 |
> |
long[] lgetArray() { return null; } |
137 |
|
abstract Object oget(int index); |
138 |
|
abstract double dget(int index); |
139 |
|
abstract long lget(int index); |
146 |
|
* oget, dget, etc. But most are overridden in most concrete |
147 |
|
* classes to avoid per-element dispatching. |
148 |
|
*/ |
149 |
+ |
|
150 |
|
void leafApply(int lo, int hi, Procedure procedure) { |
151 |
|
for (int i = lo; i < hi; ++i) |
152 |
|
if (isSelected(i)) |
276 |
|
/** |
277 |
|
* Shared support for select/map all -- probe filter, map, and |
278 |
|
* type to start selection driver, or do parallel mapping, or |
279 |
< |
* just copy, |
279 |
> |
* just copy. |
280 |
|
*/ |
281 |
|
final Object[] allObjects(Class elementType) { |
282 |
|
if (hasFilter()) { |
405 |
|
int otherOffset, BinaryLongOp combiner) {} |
406 |
|
|
407 |
|
// Base of object ref array classes |
408 |
< |
static abstract class OPap<T> extends AbstractParallelAnyArray { |
408 |
> |
abstract static class OPap<T> extends AbstractParallelAnyArray { |
409 |
|
T[] array; |
410 |
|
OPap(ForkJoinPool ex, int origin, int fence, T[] array) { |
411 |
|
super(ex, origin, fence); |
435 |
|
} |
436 |
|
|
437 |
|
// Base of double array classes |
438 |
< |
static abstract class DPap extends AbstractParallelAnyArray { |
438 |
> |
abstract static class DPap extends AbstractParallelAnyArray { |
439 |
|
double[] array; |
440 |
|
DPap(ForkJoinPool ex, int origin, int fence, double[] array) { |
441 |
|
super(ex, origin, fence); |
465 |
|
} |
466 |
|
|
467 |
|
// Base of long array classes |
468 |
< |
static abstract class LPap extends AbstractParallelAnyArray { |
468 |
> |
abstract static class LPap extends AbstractParallelAnyArray { |
469 |
|
long[] array; |
470 |
|
LPap(ForkJoinPool ex, int origin, int fence, long[] array) { |
471 |
|
super(ex, origin, fence); |
515 |
|
return new ORPap<T>(ex, origin, fence, array, selector); |
516 |
|
} |
517 |
|
|
518 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
518 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
519 |
|
(Op<? super T, ? extends U> op) { |
520 |
|
return new OUOMPap<T,U>(ex, origin, fence, array, op); |
521 |
|
} |
1171 |
|
compoundIndexedSelector(this.selector, selector)); |
1172 |
|
} |
1173 |
|
|
1174 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
1174 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
1175 |
|
(Op<? super T, ? extends U> op) { |
1176 |
|
return new OFOMPap<T,U>(ex, origin, fence, array, selector, op); |
1177 |
|
} |
1712 |
|
compoundIndexedSelector(this.selector, selector)); |
1713 |
|
} |
1714 |
|
|
1715 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
1715 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
1716 |
|
(Op<? super T, ? extends U> op) { |
1717 |
|
return new OROMPap<T,U>(ex, origin, fence, array, selector, op); |
1718 |
|
} |
2230 |
|
|
2231 |
|
// Object-mapped |
2232 |
|
|
2233 |
< |
static abstract class OOMPap<T,U> extends ParallelArrayWithMapping<T,U> { |
2233 |
> |
abstract static class OOMPap<T,U> extends ParallelArrayWithMapping<T,U> { |
2234 |
|
final Op<? super T, ? extends U> op; |
2235 |
|
OOMPap(ForkJoinPool ex, int origin, int fence, |
2236 |
|
T[] array, |
2260 |
|
} |
2261 |
|
} |
2262 |
|
|
2263 |
< |
static abstract class DOMPap<U> extends ParallelDoubleArrayWithMapping<U> { |
2263 |
> |
abstract static class DOMPap<U> extends ParallelDoubleArrayWithMapping<U> { |
2264 |
|
final DoubleToObject<? extends U> op; |
2265 |
|
DOMPap(ForkJoinPool ex, int origin, int fence, |
2266 |
|
double[] array, DoubleToObject<? extends U> op) { |
2289 |
|
} |
2290 |
|
} |
2291 |
|
|
2292 |
< |
static abstract class LOMPap<U> extends ParallelLongArrayWithMapping<U> { |
2292 |
> |
abstract static class LOMPap<U> extends ParallelLongArrayWithMapping<U> { |
2293 |
|
final LongToObject<? extends U> op; |
2294 |
|
LOMPap(ForkJoinPool ex, int origin, int fence, |
2295 |
|
long[] array, LongToObject<? extends U> op) { |
2326 |
|
super(ex, origin, fence, array, op); |
2327 |
|
} |
2328 |
|
|
2329 |
< |
public <V> ParallelArrayWithMapping<T, V> withMapping |
2329 |
> |
public <V> ParallelArrayWithMapping<T,V> withMapping |
2330 |
|
(Op<? super U, ? extends V> op) { |
2331 |
|
return new OUOMPap<T,V>(ex, origin, fence, array, |
2332 |
|
CommonOps.compoundOp(this.op, op)); |
2520 |
|
boolean hasFilter() { return true; } |
2521 |
|
boolean isSelected(int i) { return selector.op(this.array[i]); } |
2522 |
|
|
2523 |
< |
public <V> ParallelArrayWithMapping<T, V> withMapping |
2523 |
> |
public <V> ParallelArrayWithMapping<T,V> withMapping |
2524 |
|
(Op<? super U, ? extends V> op) { |
2525 |
|
return new OFOMPap<T,V> |
2526 |
|
(ex, origin, fence, array, selector, |
2775 |
|
boolean hasFilter() { return true; } |
2776 |
|
boolean isSelected(int i) { return selector.op(i, this.array[i]); } |
2777 |
|
|
2778 |
< |
public <V> ParallelArrayWithMapping<T, V> withMapping |
2778 |
> |
public <V> ParallelArrayWithMapping<T,V> withMapping |
2779 |
|
(Op<? super U, ? extends V> op) { |
2780 |
|
return new OROMPap<T,V> |
2781 |
|
(ex, origin, fence, array, selector, |
3015 |
|
|
3016 |
|
// Object-combined |
3017 |
|
|
3018 |
< |
static abstract class OOCPap<T,U> extends ParallelArrayWithMapping<T,U> { |
3018 |
> |
abstract static class OOCPap<T,U> extends ParallelArrayWithMapping<T,U> { |
3019 |
|
final IntAndObjectToObject<? super T, ? extends U> op; |
3020 |
|
OOCPap(ForkJoinPool ex, int origin, int fence, |
3021 |
|
T[] array, |
3047 |
|
} |
3048 |
|
} |
3049 |
|
|
3050 |
< |
static abstract class DOCPap<U> extends ParallelDoubleArrayWithMapping<U> { |
3050 |
> |
abstract static class DOCPap<U> extends ParallelDoubleArrayWithMapping<U> { |
3051 |
|
final IntAndDoubleToObject<? extends U> op; |
3052 |
|
DOCPap(ForkJoinPool ex, int origin, int fence, |
3053 |
|
double[] array, IntAndDoubleToObject<? extends U> op) { |
3078 |
|
} |
3079 |
|
} |
3080 |
|
|
3081 |
< |
static abstract class LOCPap<U> extends ParallelLongArrayWithMapping<U> { |
3081 |
> |
abstract static class LOCPap<U> extends ParallelLongArrayWithMapping<U> { |
3082 |
|
final IntAndLongToObject<? extends U> op; |
3083 |
|
LOCPap(ForkJoinPool ex, int origin, int fence, |
3084 |
|
long[] array, IntAndLongToObject<? extends U> op) { |
3117 |
|
super(ex, origin, fence, array, op); |
3118 |
|
} |
3119 |
|
|
3120 |
< |
public <V> ParallelArrayWithMapping<T, V> withMapping |
3120 |
> |
public <V> ParallelArrayWithMapping<T,V> withMapping |
3121 |
|
(Op<? super U, ? extends V> op) { |
3122 |
|
return new OUOCPap<T,V>(ex, origin, fence, array, |
3123 |
|
compoundIndexedOp(this.op, op)); |
3311 |
|
boolean hasFilter() { return true; } |
3312 |
|
boolean isSelected(int i) { return selector.op(this.array[i]); } |
3313 |
|
|
3314 |
< |
public <V> ParallelArrayWithMapping<T, V> withMapping |
3314 |
> |
public <V> ParallelArrayWithMapping<T,V> withMapping |
3315 |
|
(Op<? super U, ? extends V> op) { |
3316 |
|
return new OFOCPap<T,V>(ex, origin, fence, array, selector, |
3317 |
|
compoundIndexedOp(this.op, op)); |
3554 |
|
boolean hasFilter() { return true; } |
3555 |
|
boolean isSelected(int i) { return selector.op(i, this.array[i]); } |
3556 |
|
|
3557 |
< |
public <V> ParallelArrayWithMapping<T, V> withMapping |
3557 |
> |
public <V> ParallelArrayWithMapping<T,V> withMapping |
3558 |
|
(Op<? super U, ? extends V> op) { |
3559 |
|
return new OROCPap<T,V>(ex, origin, fence, array, selector, |
3560 |
|
compoundIndexedOp(this.op, op)); |
3786 |
|
|
3787 |
|
// Double-mapped |
3788 |
|
|
3789 |
< |
static abstract class ODMPap<T> extends ParallelArrayWithDoubleMapping<T> { |
3789 |
> |
abstract static class ODMPap<T> extends ParallelArrayWithDoubleMapping<T> { |
3790 |
|
final ObjectToDouble<? super T> op; |
3791 |
|
ODMPap(ForkJoinPool ex, int origin, int fence, |
3792 |
|
T[] array, ObjectToDouble<? super T> op) { |
3816 |
|
|
3817 |
|
} |
3818 |
|
|
3819 |
< |
static abstract class DDMPap extends ParallelDoubleArrayWithDoubleMapping { |
3819 |
> |
abstract static class DDMPap extends ParallelDoubleArrayWithDoubleMapping { |
3820 |
|
final DoubleOp op; |
3821 |
|
DDMPap |
3822 |
|
(ForkJoinPool ex, int origin, int fence, |
3846 |
|
} |
3847 |
|
} |
3848 |
|
|
3849 |
< |
static abstract class LDMPap extends ParallelLongArrayWithDoubleMapping { |
3849 |
> |
abstract static class LDMPap extends ParallelLongArrayWithDoubleMapping { |
3850 |
|
final LongToDouble op; |
3851 |
|
LDMPap(ForkJoinPool ex, int origin, int fence, |
3852 |
|
long[] array, LongToDouble op) { |
3894 |
|
CommonOps.compoundOp(this.op, op)); |
3895 |
|
} |
3896 |
|
|
3897 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
3897 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
3898 |
|
(DoubleToObject<? extends U> op) { |
3899 |
|
return new OUOMPap<T,U>(ex, origin, fence, array, |
3900 |
|
CommonOps.compoundOp(this.op, op)); |
4082 |
|
CommonOps.compoundOp(this.op, op)); |
4083 |
|
} |
4084 |
|
|
4085 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
4085 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
4086 |
|
(DoubleToObject<? extends U> op) { |
4087 |
|
return new OFOMPap<T,U>(ex, origin, fence, array, selector, |
4088 |
|
CommonOps.compoundOp(this.op, op)); |
4318 |
|
CommonOps.compoundOp(this.op, op)); |
4319 |
|
} |
4320 |
|
|
4321 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
4321 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
4322 |
|
(DoubleToObject<? extends U> op) { |
4323 |
|
return new OROMPap<T,U>(ex, origin, fence, array, selector, |
4324 |
|
CommonOps.compoundOp(this.op, op)); |
4532 |
|
} |
4533 |
|
|
4534 |
|
// double-combined |
4535 |
< |
static abstract class ODCPap<T> extends ParallelArrayWithDoubleMapping<T> { |
4535 |
> |
abstract static class ODCPap<T> extends ParallelArrayWithDoubleMapping<T> { |
4536 |
|
final IntAndObjectToDouble<? super T> op; |
4537 |
|
ODCPap(ForkJoinPool ex, int origin, int fence, |
4538 |
|
T[] array, IntAndObjectToDouble<? super T> op) { |
4564 |
|
|
4565 |
|
} |
4566 |
|
|
4567 |
< |
static abstract class DDCPap extends ParallelDoubleArrayWithDoubleMapping { |
4567 |
> |
abstract static class DDCPap extends ParallelDoubleArrayWithDoubleMapping { |
4568 |
|
final IntAndDoubleToDouble op; |
4569 |
|
DDCPap(ForkJoinPool ex, int origin, int fence, |
4570 |
|
double[] array, IntAndDoubleToDouble op) { |
4595 |
|
} |
4596 |
|
} |
4597 |
|
|
4598 |
< |
static abstract class LDCPap extends ParallelLongArrayWithDoubleMapping { |
4598 |
> |
abstract static class LDCPap extends ParallelLongArrayWithDoubleMapping { |
4599 |
|
final IntAndLongToDouble op; |
4600 |
|
LDCPap(ForkJoinPool ex, int origin, int fence, |
4601 |
|
long[] array, IntAndLongToDouble op) { |
4643 |
|
compoundIndexedOp(this.op, op)); |
4644 |
|
} |
4645 |
|
|
4646 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
4646 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
4647 |
|
(DoubleToObject<? extends U> op) { |
4648 |
|
return new OUOCPap<T,U>(ex, origin, fence, array, |
4649 |
|
compoundIndexedOp(this.op, op)); |
4830 |
|
compoundIndexedOp(this.op, op)); |
4831 |
|
} |
4832 |
|
|
4833 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
4833 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
4834 |
|
(DoubleToObject<? extends U> op) { |
4835 |
|
return new OFOCPap<T,U>(ex, origin, fence, array, selector, |
4836 |
|
compoundIndexedOp(this.op, op)); |
5068 |
|
compoundIndexedOp(this.op, op)); |
5069 |
|
} |
5070 |
|
|
5071 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
5071 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
5072 |
|
(DoubleToObject<? extends U> op) { |
5073 |
|
return new OROCPap<T,U>(ex, origin, fence, array, selector, |
5074 |
|
compoundIndexedOp(this.op, op)); |
5283 |
|
} |
5284 |
|
|
5285 |
|
// long-combined |
5286 |
< |
static abstract class OLMPap<T> extends ParallelArrayWithLongMapping<T> { |
5286 |
> |
abstract static class OLMPap<T> extends ParallelArrayWithLongMapping<T> { |
5287 |
|
final ObjectToLong<? super T> op; |
5288 |
|
OLMPap(ForkJoinPool ex, int origin, int fence, |
5289 |
|
T[] array, final ObjectToLong<? super T> op) { |
5312 |
|
} |
5313 |
|
} |
5314 |
|
|
5315 |
< |
static abstract class DLMPap extends ParallelDoubleArrayWithLongMapping { |
5315 |
> |
abstract static class DLMPap extends ParallelDoubleArrayWithLongMapping { |
5316 |
|
final DoubleToLong op; |
5317 |
|
DLMPap(ForkJoinPool ex, int origin, int fence, |
5318 |
|
double[] array, DoubleToLong op) { |
5342 |
|
|
5343 |
|
} |
5344 |
|
|
5345 |
< |
static abstract class LLMPap extends ParallelLongArrayWithLongMapping { |
5345 |
> |
abstract static class LLMPap extends ParallelLongArrayWithLongMapping { |
5346 |
|
final LongOp op; |
5347 |
|
LLMPap(ForkJoinPool ex, int origin, int fence, |
5348 |
|
long[] array, LongOp op) { |
5389 |
|
CommonOps.compoundOp(this.op, op)); |
5390 |
|
} |
5391 |
|
|
5392 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
5392 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
5393 |
|
(LongToObject<? extends U> op) { |
5394 |
|
return new OUOMPap<T,U>(ex, origin, fence, array, |
5395 |
|
CommonOps.compoundOp(this.op, op)); |
5578 |
|
CommonOps.compoundOp(this.op, op)); |
5579 |
|
} |
5580 |
|
|
5581 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
5581 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
5582 |
|
(LongToObject<? extends U> op) { |
5583 |
|
return new OFOMPap<T,U>(ex, origin, fence, array, selector, |
5584 |
|
CommonOps.compoundOp(this.op, op)); |
5818 |
|
CommonOps.compoundOp(this.op, op)); |
5819 |
|
} |
5820 |
|
|
5821 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
5821 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
5822 |
|
(LongToObject<? extends U> op) { |
5823 |
|
return new OROMPap<T,U>(ex, origin, fence, array, selector, |
5824 |
|
CommonOps.compoundOp(this.op, op)); |
6034 |
|
} |
6035 |
|
|
6036 |
|
// long-combined |
6037 |
< |
static abstract class OLCPap<T> extends ParallelArrayWithLongMapping<T> { |
6037 |
> |
abstract static class OLCPap<T> extends ParallelArrayWithLongMapping<T> { |
6038 |
|
final IntAndObjectToLong<? super T> op; |
6039 |
|
OLCPap(ForkJoinPool ex, int origin, int fence, |
6040 |
|
T[] array, IntAndObjectToLong<? super T> op) { |
6065 |
|
} |
6066 |
|
} |
6067 |
|
|
6068 |
< |
static abstract class DLCPap extends ParallelDoubleArrayWithLongMapping { |
6068 |
> |
abstract static class DLCPap extends ParallelDoubleArrayWithLongMapping { |
6069 |
|
final IntAndDoubleToLong op; |
6070 |
|
DLCPap(ForkJoinPool ex, int origin, int fence, |
6071 |
|
double[] array, IntAndDoubleToLong op) { |
6096 |
|
} |
6097 |
|
} |
6098 |
|
|
6099 |
< |
static abstract class LLCPap extends ParallelLongArrayWithLongMapping { |
6099 |
> |
abstract static class LLCPap extends ParallelLongArrayWithLongMapping { |
6100 |
|
final IntAndLongToLong op; |
6101 |
|
LLCPap(ForkJoinPool ex, int origin, int fence, |
6102 |
|
long[] array, IntAndLongToLong op) { |
6144 |
|
compoundIndexedOp(this.op, op)); |
6145 |
|
} |
6146 |
|
|
6147 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
6147 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
6148 |
|
(LongToObject<? extends U> op) { |
6149 |
|
return new OUOCPap<T,U>(ex, origin, fence, array, |
6150 |
|
compoundIndexedOp(this.op, op)); |
6329 |
|
compoundIndexedOp(this.op, op)); |
6330 |
|
} |
6331 |
|
|
6332 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
6332 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
6333 |
|
(LongToObject<? extends U> op) { |
6334 |
|
return new OFOCPap<T,U>(ex, origin, fence, array, |
6335 |
|
selector, |
6571 |
|
compoundIndexedOp(this.op, op)); |
6572 |
|
} |
6573 |
|
|
6574 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
6574 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
6575 |
|
(LongToObject<? extends U> op) { |
6576 |
|
return new OROCPap<T,U>(ex, origin, fence, array, |
6577 |
|
selector, |
6821 |
|
int cursor; |
6822 |
|
FilteredAsDoubleIterator() { |
6823 |
|
cursor = origin; |
6824 |
< |
advance() ; |
6824 |
> |
advance(); |
6825 |
|
} |
6826 |
|
private void advance() { |
6827 |
|
while (cursor < fence) { |
6874 |
|
int cursor; |
6875 |
|
FilteredAsLongIterator() { |
6876 |
|
cursor = origin; |
6877 |
< |
advance() ; |
6877 |
> |
advance(); |
6878 |
|
} |
6879 |
|
private void advance() { |
6880 |
|
while (cursor < fence) { |
6927 |
|
int cursor; |
6928 |
|
FilteredIterator() { |
6929 |
|
cursor = origin; |
6930 |
< |
advance() ; |
6930 |
> |
advance(); |
6931 |
|
} |
6932 |
|
private void advance() { |
6933 |
|
while (cursor < fence) { |