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; |
86 |
|
*/ |
87 |
|
public int anyIndex() { |
88 |
|
if (!hasFilter()) |
89 |
< |
return (origin < fence)? origin : -1; |
89 |
> |
return (origin < fence) ? origin : -1; |
90 |
|
AtomicInteger result = new AtomicInteger(-1); |
91 |
|
PAS.FJSelectAny f = new PAS.FJSelectAny |
92 |
|
(this, origin, fence, null, result); |
118 |
|
*/ |
119 |
|
final int getThreshold() { |
120 |
|
int t = threshold; |
121 |
< |
if (t == 0) |
121 |
> |
if (t == 0) |
122 |
|
t = computeThreshold(); |
123 |
|
return t; |
124 |
|
} |
1133 |
|
} |
1134 |
|
} |
1135 |
|
|
1136 |
+ |
static final class AndPredicate<T> implements Predicate<T> { |
1137 |
+ |
final Predicate<? super T> first; |
1138 |
+ |
final Predicate<? super T> second; |
1139 |
+ |
AndPredicate(Predicate<? super T> first, |
1140 |
+ |
Predicate<? super T> second) { |
1141 |
+ |
this.first = first; this.second = second; |
1142 |
+ |
} |
1143 |
+ |
public final boolean op(T x) { return first.op(x) && second.op(x); } |
1144 |
+ |
} |
1145 |
+ |
|
1146 |
|
// Filtered (but unmapped) classes |
1147 |
|
static final class OFPap<T> extends ParallelArrayWithFilter<T> { |
1148 |
|
final Predicate<? super T> selector; |
1159 |
|
public ParallelArrayWithFilter<T> withFilter |
1160 |
|
(Predicate<? super T> selector) { |
1161 |
|
return new OFPap<T>(ex, origin, fence, array, |
1162 |
< |
CommonOps.andPredicate(this.selector, selector)); |
1162 |
> |
new AndPredicate(this.selector, selector)); |
1163 |
|
} |
1164 |
|
|
1165 |
|
public ParallelArrayWithFilter<T> withIndexedFilter |
2393 |
|
} |
2394 |
|
|
2395 |
|
public ParallelDoubleArrayWithDoubleMapping withMapping |
2396 |
< |
(ObjectToDouble<? super U> op){ |
2396 |
> |
(ObjectToDouble<? super U> op) { |
2397 |
|
return new DUDMPap(ex, origin, fence, array, |
2398 |
|
CommonOps.compoundOp(this.op, op)); |
2399 |
|
} |
4903 |
|
} |
4904 |
|
|
4905 |
|
public ParallelDoubleArrayWithLongMapping withMapping(DoubleToLong op) { |
4906 |
< |
return new DFLCPap (ex, origin, fence, array, selector, |
4907 |
< |
compoundIndexedOp(this.op, op)); |
4906 |
> |
return new DFLCPap(ex, origin, fence, array, selector, |
4907 |
> |
compoundIndexedOp(this.op, op)); |
4908 |
|
} |
4909 |
|
|
4910 |
|
public <U> ParallelDoubleArrayWithMapping< U> withMapping |
5141 |
|
} |
5142 |
|
|
5143 |
|
public ParallelDoubleArrayWithLongMapping withMapping(DoubleToLong op) { |
5144 |
< |
return new DRLCPap (ex, origin, fence, array, selector, |
5145 |
< |
compoundIndexedOp(this.op, op)); |
5144 |
> |
return new DRLCPap(ex, origin, fence, array, selector, |
5145 |
> |
compoundIndexedOp(this.op, op)); |
5146 |
|
} |
5147 |
|
|
5148 |
|
public <U> ParallelDoubleArrayWithMapping< U> withMapping |