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 ParallelArray that causes operations to apply |
24 |
|
} |
25 |
|
|
26 |
|
/** |
27 |
< |
* Applies the given procedure |
27 |
> |
* Applies the given procedure. |
28 |
|
* @param procedure the procedure |
29 |
|
*/ |
30 |
|
public void apply(LongProcedure 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 |
45 |
|
} |
46 |
|
|
47 |
|
/** |
48 |
< |
* Returns the minimum element, or Long.MAX_VALUE if empty |
48 |
> |
* Returns the minimum element, or Long.MAX_VALUE if empty. |
49 |
|
* @return minimum element, or Long.MAX_VALUE if empty |
50 |
|
*/ |
51 |
|
public long min() { |
53 |
|
} |
54 |
|
|
55 |
|
/** |
56 |
< |
* Returns the minimum element, or Long.MAX_VALUE if empty |
56 |
> |
* Returns the minimum element, or Long.MAX_VALUE if empty. |
57 |
|
* @param comparator the comparator |
58 |
|
* @return minimum element, or Long.MAX_VALUE if empty |
59 |
|
*/ |
62 |
|
} |
63 |
|
|
64 |
|
/** |
65 |
< |
* Returns the maximum element, or Long.MIN_VALUE if empty |
65 |
> |
* Returns the maximum element, or Long.MIN_VALUE if empty. |
66 |
|
* @return maximum element, or Long.MIN_VALUE if empty |
67 |
|
*/ |
68 |
|
public long max() { |
70 |
|
} |
71 |
|
|
72 |
|
/** |
73 |
< |
* Returns the maximum element, or Long.MIN_VALUE if empty |
73 |
> |
* Returns the maximum element, or Long.MIN_VALUE if empty. |
74 |
|
* @param comparator the comparator |
75 |
|
* @return maximum element, or Long.MIN_VALUE if empty |
76 |
|
*/ |
79 |
|
} |
80 |
|
|
81 |
|
/** |
82 |
< |
* Returns the sum of elements |
82 |
> |
* Returns the sum of elements. |
83 |
|
* @return the sum of elements |
84 |
|
*/ |
85 |
|
public long sum() { |
87 |
|
} |
88 |
|
|
89 |
|
/** |
90 |
< |
* Returns summary statistics |
90 |
> |
* Returns summary statistics. |
91 |
|
* @param comparator the comparator to use for |
92 |
|
* locating minimum and maximum elements |
93 |
< |
* @return the summary. |
93 |
> |
* @return the summary |
94 |
|
*/ |
95 |
|
public ParallelLongArray.SummaryStatistics summary |
96 |
|
(LongComparator comparator) { |
101 |
|
} |
102 |
|
|
103 |
|
/** |
104 |
< |
* Returns summary statistics, using natural comparator |
105 |
< |
* @return the summary. |
104 |
> |
* Returns summary statistics, using natural comparator. |
105 |
> |
* @return the summary |
106 |
|
*/ |
107 |
|
public ParallelLongArray.SummaryStatistics summary() { |
108 |
|
return summary(CommonOps.naturalLongComparator()); |
109 |
|
} |
110 |
|
|
111 |
|
/** |
112 |
< |
* Returns a new ParallelLongArray holding mappings |
112 |
> |
* Returns a new ParallelLongArray holding mappings. |
113 |
|
* @return a new ParallelLongArray holding mappings |
114 |
|
*/ |
115 |
|
public ParallelLongArray all() { |
138 |
|
* @param op the op |
139 |
|
* @return operation prefix |
140 |
|
*/ |
141 |
< |
public abstract <U> ParallelArrayWithMapping<T, U> withMapping |
141 |
> |
public abstract <U> ParallelArrayWithMapping<T,U> withMapping |
142 |
|
(LongToObject<? extends U> op); |
143 |
|
|
144 |
|
/** |
148 |
|
* @param other the other array |
149 |
|
* @return operation prefix |
150 |
|
* @throws IllegalArgumentException if other array is a |
151 |
< |
* filtered view (all filters must precede all mappings). |
151 |
> |
* filtered view (all filters must precede all mappings) |
152 |
|
*/ |
153 |
|
public <V,W,X> ParallelArrayWithMapping<T,W> withMapping |
154 |
|
(LongAndObjectToObject<? super V, ? extends W> combiner, |
165 |
|
* @param other the other array |
166 |
|
* @return operation prefix |
167 |
|
* @throws IllegalArgumentException if other array is a |
168 |
< |
* filtered view (all filters must precede all mappings). |
168 |
> |
* filtered view (all filters must precede all mappings) |
169 |
|
*/ |
170 |
|
public <V> ParallelArrayWithMapping<T,V> withMapping |
171 |
|
(LongAndDoubleToObject<? extends V> combiner, |
182 |
|
* @param other the other array |
183 |
|
* @return operation prefix |
184 |
|
* @throws IllegalArgumentException if other array is a |
185 |
< |
* filtered view (all filters must precede all mappings). |
185 |
> |
* filtered view (all filters must precede all mappings) |
186 |
|
*/ |
187 |
|
public <V> ParallelArrayWithMapping<T,V> withMapping |
188 |
|
(LongAndLongToObject<? extends V> combiner, |
199 |
|
* @param other the other array |
200 |
|
* @return operation prefix |
201 |
|
* @throws IllegalArgumentException if other array is a |
202 |
< |
* filtered view (all filters must precede all mappings). |
202 |
> |
* filtered view (all filters must precede all mappings) |
203 |
|
*/ |
204 |
|
public <V,W> ParallelArrayWithDoubleMapping<T> withMapping |
205 |
|
(LongAndObjectToDouble<? super V> combiner, |
216 |
|
* @param other the other array |
217 |
|
* @return operation prefix |
218 |
|
* @throws IllegalArgumentException if other array is a |
219 |
< |
* filtered view (all filters must precede all mappings). |
219 |
> |
* filtered view (all filters must precede all mappings) |
220 |
|
*/ |
221 |
|
public ParallelArrayWithDoubleMapping<T> withMapping |
222 |
|
(LongAndDoubleToDouble combiner, |
234 |
|
* @param other the other array |
235 |
|
* @return operation prefix |
236 |
|
* @throws IllegalArgumentException if other array is a |
237 |
< |
* filtered view (all filters must precede all mappings). |
237 |
> |
* filtered view (all filters must precede all mappings) |
238 |
|
*/ |
239 |
|
public ParallelArrayWithDoubleMapping<T> withMapping |
240 |
|
(LongAndLongToDouble combiner, |
251 |
|
* @param other the other array |
252 |
|
* @return operation prefix |
253 |
|
* @throws IllegalArgumentException if other array is a |
254 |
< |
* filtered view (all filters must precede all mappings). |
254 |
> |
* filtered view (all filters must precede all mappings) |
255 |
|
*/ |
256 |
|
public <V,W> ParallelArrayWithLongMapping<T> withMapping |
257 |
|
(LongAndObjectToLong<? super V> combiner, |
269 |
|
* @param other the other array |
270 |
|
* @return operation prefix |
271 |
|
* @throws IllegalArgumentException if other array is a |
272 |
< |
* filtered view (all filters must precede all mappings). |
272 |
> |
* filtered view (all filters must precede all mappings) |
273 |
|
*/ |
274 |
|
public ParallelArrayWithLongMapping<T> withMapping |
275 |
|
(LongAndDoubleToLong combiner, |
287 |
|
* @param other the other array |
288 |
|
* @return operation prefix |
289 |
|
* @throws IllegalArgumentException if other array is a |
290 |
< |
* filtered view (all filters must precede all mappings). |
290 |
> |
* filtered view (all filters must precede all mappings) |
291 |
|
*/ |
292 |
|
public ParallelArrayWithLongMapping<T> withMapping |
293 |
|
(BinaryLongOp combiner, |
336 |
|
/** |
337 |
|
* Returns an Iterable view to sequentially step through mapped |
338 |
|
* elements also obeying bound and filter constraints, without |
339 |
< |
* performing computations to evaluate them in parallel |
339 |
> |
* performing computations to evaluate them in parallel. |
340 |
|
* @return the Iterable view |
341 |
|
*/ |
342 |
|
public Iterable<Long> sequentially() { |