5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import jsr166y.*; |
10 |
|
import static extra166y.Ops.*; |
11 |
|
import java.util.*; |
134 |
|
* public boolean op(Student s) { return s.credits > 90; } |
135 |
|
* } |
136 |
|
* static final IsSenior isSenior = new IsSenior(); |
137 |
< |
* static final class GpaField implements ObjectToDouble<Student> { |
137 |
> |
* static final class GpaField implements ObjectToDouble<Student> { |
138 |
|
* public double op(Student s) { return s.gpa; } |
139 |
|
* } |
140 |
|
* static final GpaField gpaField = new GpaField(); |
527 |
|
* 2, 3}, and the reducer operation adds numbers, then after |
528 |
|
* invocation of this method, the contents would be {@code 0, 1, |
529 |
|
* 3} (that is, {@code 0, 0+1, 0+1+2}, and the return value |
530 |
< |
* would be 6 (that is, {@code 1+2+3}). |
530 |
> |
* would be 6 (that is, {@code 1+2+3}). |
531 |
|
* @param reducer the reducer |
532 |
|
* @param base the result for an empty array |
533 |
|
* @return the total reduction |
552 |
|
* Sorts the array, assuming all elements are Comparable. Unlike |
553 |
|
* Arrays.sort, this sort does not guarantee that elements |
554 |
|
* with equal keys maintain their relative position in the array. |
554 |
– |
* @throws ClassCastException if any element is not Comparable |
555 |
|
* @return this (to simplify use in expressions) |
556 |
+ |
* @throws ClassCastException if any element is not Comparable |
557 |
|
*/ |
558 |
|
public ParallelArray<T> sort() { |
559 |
|
super.sort(); |
1353 |
|
return a; |
1354 |
|
} |
1355 |
|
|
1356 |
< |
public <V> V[] toArray(V a[]) { |
1356 |
> |
public <V> V[] toArray(V[] a) { |
1357 |
|
int len = fence; |
1358 |
|
if (a.length < len) { |
1359 |
|
Class elementType = a.getClass().getComponentType(); |