5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import jsr166y.*; |
10 |
|
import static extra166y.Ops.*; |
11 |
|
import java.util.*; |
25 |
|
} |
26 |
|
|
27 |
|
/** |
28 |
< |
* Applies the given procedure to elements |
28 |
> |
* Applies the given procedure to elements. |
29 |
|
* @param procedure the procedure |
30 |
|
*/ |
31 |
|
public void apply(Procedure<? super U> procedure) { |
33 |
|
} |
34 |
|
|
35 |
|
/** |
36 |
< |
* Returns reduction of elements |
36 |
> |
* Returns reduction of elements. |
37 |
|
* @param reducer the reducer |
38 |
|
* @param base the result for an empty array |
39 |
|
* @return reduction |
48 |
|
/** |
49 |
|
* Returns some element matching bound and filter |
50 |
|
* constraints, or null if none. |
51 |
< |
* @return an element, or null if none. |
51 |
> |
* @return an element, or null if none |
52 |
|
*/ |
53 |
|
public U any() { |
54 |
|
int i = anyIndex(); |
56 |
|
} |
57 |
|
|
58 |
|
/** |
59 |
< |
* Returns the minimum element, or null if empty |
59 |
> |
* Returns the minimum element, or null if empty. |
60 |
|
* @param comparator the comparator |
61 |
|
* @return minimum element, or null if empty |
62 |
|
*/ |
66 |
|
|
67 |
|
/** |
68 |
|
* Returns the minimum element, or null if empty, |
69 |
< |
* assuming that all elements are Comparables |
69 |
> |
* assuming that all elements are Comparables. |
70 |
|
* @return minimum element, or null if empty |
71 |
< |
* @throws ClassCastException if any element is not Comparable. |
71 |
> |
* @throws ClassCastException if any element is not Comparable |
72 |
|
*/ |
73 |
|
public U min() { |
74 |
|
return reduce((Reducer<U>)(CommonOps.castedMinReducer()), null); |
75 |
|
} |
76 |
|
|
77 |
|
/** |
78 |
< |
* Returns the maximum element, or null if empty |
78 |
> |
* Returns the maximum element, or null if empty. |
79 |
|
* @param comparator the comparator |
80 |
|
* @return maximum element, or null if empty |
81 |
|
*/ |
84 |
|
} |
85 |
|
|
86 |
|
/** |
87 |
< |
* Returns the maximum element, or null if empty |
88 |
< |
* assuming that all elements are Comparables |
87 |
> |
* Returns the maximum element, or null if empty, |
88 |
> |
* assuming that all elements are Comparables. |
89 |
|
* @return maximum element, or null if empty |
90 |
< |
* @throws ClassCastException if any element is not Comparable. |
90 |
> |
* @throws ClassCastException if any element is not Comparable |
91 |
|
*/ |
92 |
|
public U max() { |
93 |
|
return reduce((Reducer<U>)(CommonOps.castedMaxReducer()), null); |
98 |
|
* to locate minimum and maximum elements. |
99 |
|
* @param comparator the comparator to use for |
100 |
|
* locating minimum and maximum elements |
101 |
< |
* @return the summary. |
101 |
> |
* @return the summary |
102 |
|
*/ |
103 |
|
public ParallelArray.SummaryStatistics<U> summary |
104 |
|
(Comparator<? super U> comparator) { |
110 |
|
|
111 |
|
/** |
112 |
|
* Returns summary statistics, assuming that all elements are |
113 |
< |
* Comparables |
114 |
< |
* @return the summary. |
113 |
> |
* Comparables. |
114 |
> |
* @return the summary |
115 |
|
*/ |
116 |
|
public ParallelArray.SummaryStatistics<U> summary() { |
117 |
|
return summary((Comparator<? super U>)(CommonOps.castedComparator())); |
118 |
|
} |
119 |
|
|
120 |
|
/** |
121 |
< |
* Returns a new ParallelArray holding elements |
121 |
> |
* Returns a new ParallelArray holding elements. |
122 |
|
* @return a new ParallelArray holding elements |
123 |
|
*/ |
124 |
|
public ParallelArray<U> all() { |
127 |
|
|
128 |
|
/** |
129 |
|
* Returns a new ParallelArray with the given element type |
130 |
< |
* holding elements |
130 |
> |
* holding elements. |
131 |
|
* @param elementType the type of the elements |
132 |
|
* @return a new ParallelArray holding elements |
133 |
|
*/ |
138 |
|
/** |
139 |
|
* Returns an operation prefix that causes a method to operate |
140 |
|
* on mapped elements of the array using the given op |
141 |
< |
* applied to current op's results |
141 |
> |
* applied to current op's results. |
142 |
|
* @param op the op |
143 |
|
* @return operation prefix |
144 |
|
*/ |
145 |
< |
public abstract <V> ParallelArrayWithMapping<T, V> withMapping |
145 |
> |
public abstract <V> ParallelArrayWithMapping<T,V> withMapping |
146 |
|
(Op<? super U, ? extends V> op); |
147 |
|
|
148 |
|
/** |
149 |
|
* Returns an operation prefix that causes a method to operate |
150 |
|
* on mapped elements of the array using the given op |
151 |
< |
* applied to current op's results |
151 |
> |
* applied to current op's results. |
152 |
|
* @param op the op |
153 |
|
* @return operation prefix |
154 |
|
*/ |
158 |
|
/** |
159 |
|
* Returns an operation prefix that causes a method to operate |
160 |
|
* on mapped elements of the array using the given op |
161 |
< |
* applied to current op's results |
161 |
> |
* applied to current op's results. |
162 |
|
* @param op the op |
163 |
|
* @return operation prefix |
164 |
|
*/ |
172 |
|
* @param other the other array |
173 |
|
* @return operation prefix |
174 |
|
* @throws IllegalArgumentException if other array is a |
175 |
< |
* filtered view (all filters must precede all mappings). |
175 |
> |
* filtered view (all filters must precede all mappings) |
176 |
|
*/ |
177 |
|
public <V,W,X> ParallelArrayWithMapping<T,W> withMapping |
178 |
|
(BinaryOp<? super U, ? super V, ? extends W> combiner, |
189 |
|
* @param other the other array |
190 |
|
* @return operation prefix |
191 |
|
* @throws IllegalArgumentException if other array is a |
192 |
< |
* filtered view (all filters must precede all mappings). |
192 |
> |
* filtered view (all filters must precede all mappings) |
193 |
|
*/ |
194 |
|
public <V> ParallelArrayWithMapping<T,V> withMapping |
195 |
|
(ObjectAndDoubleToObject<? super U, ? extends V> combiner, |
206 |
|
* @param other the other array |
207 |
|
* @return operation prefix |
208 |
|
* @throws IllegalArgumentException if other array is a |
209 |
< |
* filtered view (all filters must precede all mappings). |
209 |
> |
* filtered view (all filters must precede all mappings) |
210 |
|
*/ |
211 |
|
public <V> ParallelArrayWithMapping<T,V> withMapping |
212 |
|
(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> ParallelArrayWithDoubleMapping<T> 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 ParallelArrayWithDoubleMapping<T> withMapping |
246 |
|
(ObjectAndDoubleToDouble<? super U> combiner, |
257 |
|
* @param other the other array |
258 |
|
* @return operation prefix |
259 |
|
* @throws IllegalArgumentException if other array is a |
260 |
< |
* filtered view (all filters must precede all mappings). |
260 |
> |
* filtered view (all filters must precede all mappings) |
261 |
|
*/ |
262 |
|
public ParallelArrayWithDoubleMapping<T> withMapping |
263 |
|
(ObjectAndLongToDouble<? super U> combiner, |
274 |
|
* @param other the other array |
275 |
|
* @return operation prefix |
276 |
|
* @throws IllegalArgumentException if other array is a |
277 |
< |
* filtered view (all filters must precede all mappings). |
277 |
> |
* filtered view (all filters must precede all mappings) |
278 |
|
*/ |
279 |
|
public <V,W> ParallelArrayWithLongMapping<T> withMapping |
280 |
|
(ObjectAndObjectToLong<? super U, ? super V> combiner, |
291 |
|
* @param other the other array |
292 |
|
* @return operation prefix |
293 |
|
* @throws IllegalArgumentException if other array is a |
294 |
< |
* filtered view (all filters must precede all mappings). |
294 |
> |
* filtered view (all filters must precede all mappings) |
295 |
|
*/ |
296 |
|
public ParallelArrayWithLongMapping<T> withMapping |
297 |
|
(ObjectAndDoubleToLong<? super U> combiner, |
308 |
|
* @param other the other array |
309 |
|
* @return operation prefix |
310 |
|
* @throws IllegalArgumentException if other array is a |
311 |
< |
* filtered view (all filters must precede all mappings). |
311 |
> |
* filtered view (all filters must precede all mappings) |
312 |
|
*/ |
313 |
|
public ParallelArrayWithLongMapping<T> withMapping |
314 |
|
(ObjectAndLongToLong<? super U> combiner, |
357 |
|
/** |
358 |
|
* Returns an Iterable view to sequentially step through mapped |
359 |
|
* elements also obeying bound and filter constraints, without |
360 |
< |
* performing computations to evaluate them in parallel |
360 |
> |
* performing computations to evaluate them in parallel. |
361 |
|
* @return the Iterable view |
362 |
|
*/ |
363 |
|
public Iterable<U> sequentially() { |