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; |
8 |
+ |
|
9 |
|
import jsr166y.*; |
10 |
|
import static extra166y.Ops.*; |
11 |
|
import java.util.*; |
25 |
|
} |
26 |
|
|
27 |
|
/** |
28 |
< |
* Applies the given procedure to mapped elements |
28 |
> |
* Applies the given procedure to mapped elements. |
29 |
|
* @param procedure the procedure |
30 |
|
*/ |
31 |
|
public void apply(Procedure<? super U> procedure) { |
33 |
|
} |
34 |
|
|
35 |
|
/** |
36 |
< |
* Returns reduction of mapped elements |
36 |
> |
* Returns reduction of mapped elements. |
37 |
|
* @param reducer the reducer |
38 |
|
* @param base the result for an empty array |
39 |
|
* @return reduction |
48 |
|
/** |
49 |
|
* Returns mapping of some element matching bound and filter |
50 |
|
* constraints, or null if none. |
51 |
< |
* @return mapping of matching element, or null if none. |
51 |
> |
* @return mapping of matching element, or null if none |
52 |
|
*/ |
53 |
|
public U any() { |
54 |
|
int i = anyIndex(); |
56 |
|
} |
57 |
|
|
58 |
|
/** |
59 |
< |
* Returns the minimum mapped element, or null if empty |
59 |
> |
* Returns the minimum mapped element, or null if empty. |
60 |
|
* @param comparator the comparator |
61 |
|
* @return minimum mapped element, or null if empty |
62 |
|
*/ |
66 |
|
|
67 |
|
/** |
68 |
|
* Returns the minimum mapped element, or null if empty, |
69 |
< |
* assuming that all elements are Comparables |
69 |
> |
* assuming that all elements are Comparables. |
70 |
|
* @return minimum mapped 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 mapped element, or null if empty |
78 |
> |
* Returns the maximum mapped element, or null if empty. |
79 |
|
* @param comparator the comparator |
80 |
|
* @return maximum mapped element, or null if empty |
81 |
|
*/ |
84 |
|
} |
85 |
|
|
86 |
|
/** |
87 |
< |
* Returns the maximum mapped element, or null if empty |
88 |
< |
* assuming that all elements are Comparables |
87 |
> |
* Returns the maximum mapped element, or null if empty, |
88 |
> |
* assuming that all elements are Comparables. |
89 |
|
* @return maximum mapped 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 holding |
130 |
< |
* elements |
130 |
> |
* 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 |
|
*/ |
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> ParallelDoubleArrayWithMapping<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> ParallelDoubleArrayWithMapping<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> ParallelDoubleArrayWithMapping<V> withMapping |
212 |
|
(ObjectAndLongToObject<? super U, ? extends V> combiner, |
224 |
|
* @param other the other array |
225 |
|
* @return operation prefix |
226 |
|
* @throws IllegalArgumentException if other array is a |
227 |
< |
* filtered view (all filters must precede all mappings). |
227 |
> |
* filtered view (all filters must precede all mappings) |
228 |
|
*/ |
229 |
|
public <V,W> ParallelDoubleArrayWithDoubleMapping withMapping |
230 |
|
(ObjectAndObjectToDouble<? super U, ? super V> combiner, |
241 |
|
* @param other the other array |
242 |
|
* @return operation prefix |
243 |
|
* @throws IllegalArgumentException if other array is a |
244 |
< |
* filtered view (all filters must precede all mappings). |
244 |
> |
* filtered view (all filters must precede all mappings) |
245 |
|
*/ |
246 |
|
public ParallelDoubleArrayWithDoubleMapping withMapping |
247 |
|
(ObjectAndDoubleToDouble<? super U> combiner, |
273 |
|
* @param other the other array |
274 |
|
* @return operation prefix |
275 |
|
* @throws IllegalArgumentException if other array is a |
276 |
< |
* filtered view (all filters must precede all mappings). |
276 |
> |
* filtered view (all filters must precede all mappings) |
277 |
|
*/ |
278 |
|
public <V,W> ParallelDoubleArrayWithLongMapping withMapping |
279 |
|
(ObjectAndObjectToLong<? super U, ? super V> combiner, |
290 |
|
* @param other the other array |
291 |
|
* @return operation prefix |
292 |
|
* @throws IllegalArgumentException if other array is a |
293 |
< |
* filtered view (all filters must precede all mappings). |
293 |
> |
* filtered view (all filters must precede all mappings) |
294 |
|
*/ |
295 |
|
public ParallelDoubleArrayWithLongMapping withMapping |
296 |
|
(ObjectAndDoubleToLong<? super U> combiner, |
307 |
|
* @param other the other array |
308 |
|
* @return operation prefix |
309 |
|
* @throws IllegalArgumentException if other array is a |
310 |
< |
* filtered view (all filters must precede all mappings). |
310 |
> |
* filtered view (all filters must precede all mappings) |
311 |
|
*/ |
312 |
|
public ParallelDoubleArrayWithLongMapping withMapping |
313 |
|
(ObjectAndLongToLong<? super U> combiner, |
356 |
|
/** |
357 |
|
* Returns an Iterable view to sequentially step through mapped |
358 |
|
* elements also obeying bound and filter constraints, without |
359 |
< |
* performing computations to evaluate them in parallel |
359 |
> |
* performing computations to evaluate them in parallel. |
360 |
|
* @return the Iterable view |
361 |
|
*/ |
362 |
|
public Iterable<U> sequentially() { |
364 |
|
} |
365 |
|
|
366 |
|
} |
366 |
– |
|