5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import jsr166y.*; |
10 |
|
import static extra166y.Ops.*; |
11 |
|
import java.util.*; |
12 |
|
import java.util.concurrent.atomic.*; |
12 |
– |
import java.lang.reflect.Array; |
13 |
|
|
14 |
|
/** |
15 |
|
* A prefix view of ParallelDoubleArray that causes operations to apply |
24 |
|
} |
25 |
|
|
26 |
|
/** |
27 |
< |
* Applies the given procedure to mapped elements |
27 |
> |
* Applies the given procedure to mapped elements. |
28 |
|
* @param procedure the procedure |
29 |
|
*/ |
30 |
|
public void apply(Procedure<? super U> procedure) { |
32 |
|
} |
33 |
|
|
34 |
|
/** |
35 |
< |
* Returns reduction of mapped elements |
35 |
> |
* Returns reduction of mapped elements. |
36 |
|
* @param reducer the reducer |
37 |
|
* @param base the result for an empty array |
38 |
|
* @return reduction |
47 |
|
/** |
48 |
|
* Returns mapping of some element matching bound and filter |
49 |
|
* constraints, or null if none. |
50 |
< |
* @return mapping of matching element, or null if none. |
50 |
> |
* @return mapping of matching element, or null if none |
51 |
|
*/ |
52 |
|
public U any() { |
53 |
|
int i = anyIndex(); |
55 |
|
} |
56 |
|
|
57 |
|
/** |
58 |
< |
* Returns the minimum mapped element, or null if empty |
58 |
> |
* Returns the minimum mapped element, or null if empty. |
59 |
|
* @param comparator the comparator |
60 |
|
* @return minimum mapped element, or null if empty |
61 |
|
*/ |
65 |
|
|
66 |
|
/** |
67 |
|
* Returns the minimum mapped element, or null if empty, |
68 |
< |
* assuming that all elements are Comparables |
68 |
> |
* assuming that all elements are Comparables. |
69 |
|
* @return minimum mapped element, or null if empty |
70 |
< |
* @throws ClassCastException if any element is not Comparable. |
70 |
> |
* @throws ClassCastException if any element is not Comparable |
71 |
|
*/ |
72 |
|
public U min() { |
73 |
|
return reduce((Reducer<U>)(CommonOps.castedMinReducer()), null); |
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
< |
* Returns the maximum mapped element, or null if empty |
77 |
> |
* Returns the maximum mapped element, or null if empty. |
78 |
|
* @param comparator the comparator |
79 |
|
* @return maximum mapped element, or null if empty |
80 |
|
*/ |
83 |
|
} |
84 |
|
|
85 |
|
/** |
86 |
< |
* Returns the maximum mapped element, or null if empty |
87 |
< |
* assuming that all elements are Comparables |
86 |
> |
* Returns the maximum mapped element, or null if empty, |
87 |
> |
* assuming that all elements are Comparables. |
88 |
|
* @return maximum mapped element, or null if empty |
89 |
< |
* @throws ClassCastException if any element is not Comparable. |
89 |
> |
* @throws ClassCastException if any element is not Comparable |
90 |
|
*/ |
91 |
|
public U max() { |
92 |
|
return reduce((Reducer<U>)(CommonOps.castedMaxReducer()), null); |
97 |
|
* to locate minimum and maximum elements. |
98 |
|
* @param comparator the comparator to use for |
99 |
|
* locating minimum and maximum elements |
100 |
< |
* @return the summary. |
100 |
> |
* @return the summary |
101 |
|
*/ |
102 |
|
public ParallelArray.SummaryStatistics<U> summary |
103 |
|
(Comparator<? super U> comparator) { |
109 |
|
|
110 |
|
/** |
111 |
|
* Returns summary statistics, assuming that all elements are |
112 |
< |
* Comparables |
113 |
< |
* @return the summary. |
112 |
> |
* Comparables. |
113 |
> |
* @return the summary |
114 |
|
*/ |
115 |
|
public ParallelArray.SummaryStatistics<U> summary() { |
116 |
|
return summary((Comparator<? super U>)(CommonOps.castedComparator())); |
117 |
|
} |
118 |
|
|
119 |
|
/** |
120 |
< |
* Returns a new ParallelArray holding elements |
120 |
> |
* Returns a new ParallelArray holding elements. |
121 |
|
* @return a new ParallelArray holding elements |
122 |
|
*/ |
123 |
|
public ParallelArray<U> all() { |
126 |
|
|
127 |
|
/** |
128 |
|
* Returns a new ParallelArray with the given element type holding |
129 |
< |
* elements |
129 |
> |
* elements. |
130 |
|
* @param elementType the type of the elements |
131 |
|
* @return a new ParallelArray holding elements |
132 |
|
*/ |
137 |
|
/** |
138 |
|
* Returns an operation prefix that causes a method to operate |
139 |
|
* on mapped elements of the array using the given op |
140 |
< |
* applied to current op's results |
140 |
> |
* applied to current op's results. |
141 |
|
* @param op the op |
142 |
|
* @return operation prefix |
143 |
|
*/ |
147 |
|
/** |
148 |
|
* Returns an operation prefix that causes a method to operate |
149 |
|
* on mapped elements of the array using the given op |
150 |
< |
* applied to current op's results |
150 |
> |
* applied to current op's results. |
151 |
|
* @param op the op |
152 |
|
* @return operation prefix |
153 |
|
*/ |
157 |
|
/** |
158 |
|
* Returns an operation prefix that causes a method to operate |
159 |
|
* on mapped elements of the array using the given op |
160 |
< |
* applied to current op's results |
160 |
> |
* applied to current op's results. |
161 |
|
* @param op the op |
162 |
|
* @return operation prefix |
163 |
|
*/ |
171 |
|
* @param other the other array |
172 |
|
* @return operation prefix |
173 |
|
* @throws IllegalArgumentException if other array is a |
174 |
< |
* filtered view (all filters must precede all mappings). |
174 |
> |
* filtered view (all filters must precede all mappings) |
175 |
|
*/ |
176 |
|
public <V,W,X> ParallelDoubleArrayWithMapping<W> withMapping |
177 |
|
(BinaryOp<? super U, ? super V, ? extends W> combiner, |
188 |
|
* @param other the other array |
189 |
|
* @return operation prefix |
190 |
|
* @throws IllegalArgumentException if other array is a |
191 |
< |
* filtered view (all filters must precede all mappings). |
191 |
> |
* filtered view (all filters must precede all mappings) |
192 |
|
*/ |
193 |
|
public <V> ParallelDoubleArrayWithMapping<V> withMapping |
194 |
|
(ObjectAndDoubleToObject<? super U, ? extends V> combiner, |
205 |
|
* @param other the other array |
206 |
|
* @return operation prefix |
207 |
|
* @throws IllegalArgumentException if other array is a |
208 |
< |
* filtered view (all filters must precede all mappings). |
208 |
> |
* filtered view (all filters must precede all mappings) |
209 |
|
*/ |
210 |
|
public <V> ParallelDoubleArrayWithMapping<V> withMapping |
211 |
|
(ObjectAndLongToObject<? super U, ? extends V> combiner, |
223 |
|
* @param other the other array |
224 |
|
* @return operation prefix |
225 |
|
* @throws IllegalArgumentException if other array is a |
226 |
< |
* filtered view (all filters must precede all mappings). |
226 |
> |
* filtered view (all filters must precede all mappings) |
227 |
|
*/ |
228 |
|
public <V,W> ParallelDoubleArrayWithDoubleMapping withMapping |
229 |
|
(ObjectAndObjectToDouble<? super U, ? super V> combiner, |
240 |
|
* @param other the other array |
241 |
|
* @return operation prefix |
242 |
|
* @throws IllegalArgumentException if other array is a |
243 |
< |
* filtered view (all filters must precede all mappings). |
243 |
> |
* filtered view (all filters must precede all mappings) |
244 |
|
*/ |
245 |
|
public ParallelDoubleArrayWithDoubleMapping withMapping |
246 |
|
(ObjectAndDoubleToDouble<? super U> combiner, |
272 |
|
* @param other the other array |
273 |
|
* @return operation prefix |
274 |
|
* @throws IllegalArgumentException if other array is a |
275 |
< |
* filtered view (all filters must precede all mappings). |
275 |
> |
* filtered view (all filters must precede all mappings) |
276 |
|
*/ |
277 |
|
public <V,W> ParallelDoubleArrayWithLongMapping withMapping |
278 |
|
(ObjectAndObjectToLong<? super U, ? super V> combiner, |
289 |
|
* @param other the other array |
290 |
|
* @return operation prefix |
291 |
|
* @throws IllegalArgumentException if other array is a |
292 |
< |
* filtered view (all filters must precede all mappings). |
292 |
> |
* filtered view (all filters must precede all mappings) |
293 |
|
*/ |
294 |
|
public ParallelDoubleArrayWithLongMapping withMapping |
295 |
|
(ObjectAndDoubleToLong<? super U> combiner, |
306 |
|
* @param other the other array |
307 |
|
* @return operation prefix |
308 |
|
* @throws IllegalArgumentException if other array is a |
309 |
< |
* filtered view (all filters must precede all mappings). |
309 |
> |
* filtered view (all filters must precede all mappings) |
310 |
|
*/ |
311 |
|
public ParallelDoubleArrayWithLongMapping withMapping |
312 |
|
(ObjectAndLongToLong<? super U> combiner, |
355 |
|
/** |
356 |
|
* Returns an Iterable view to sequentially step through mapped |
357 |
|
* elements also obeying bound and filter constraints, without |
358 |
< |
* performing computations to evaluate them in parallel |
358 |
> |
* performing computations to evaluate them in parallel. |
359 |
|
* @return the Iterable view |
360 |
|
*/ |
361 |
|
public Iterable<U> sequentially() { |