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(); |
510 |
|
* the given reducer. For example, if the contents are the numbers |
511 |
|
* {@code 1, 2, 3}, and the reducer operation adds numbers, then |
512 |
|
* after invocation of this method, the contents would be {@code 1, |
513 |
< |
* 3, 6} (that is, {@code 1, 1+2, 1+2+3}); |
513 |
> |
* 3, 6} (that is, {@code 1, 1+2, 1+2+3}). |
514 |
|
* @param reducer the reducer |
515 |
|
* @param base the result for an empty array |
516 |
|
* @return this (to simplify use in expressions) |
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 |
534 |
|
*/ |
535 |
|
public T precumulate(Reducer<T> reducer, T base) { |
536 |
< |
return (T)(super.precumulate(reducer, base)); |
536 |
> |
return super.precumulate(reducer, base); |
537 |
|
} |
538 |
|
|
539 |
|
/** |
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(); |
756 |
|
* @param op the op |
757 |
|
* @return operation prefix |
758 |
|
*/ |
759 |
< |
public <U> ParallelArrayWithMapping<T, U> withMapping |
759 |
> |
public <U> ParallelArrayWithMapping<T,U> withMapping |
760 |
|
(Op<? super T, ? extends U> op) { |
761 |
|
return super.withMapping(op); |
762 |
|
} |
1038 |
|
public T[] getArray() { return array; } |
1039 |
|
|
1040 |
|
/** |
1041 |
< |
* Equivalent to {@code asList().toString()} |
1041 |
> |
* Equivalent to {@code asList().toString()}. |
1042 |
|
* @return a string representation |
1043 |
|
*/ |
1044 |
|
public String toString() { |
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(); |