5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import jsr166y.*; |
10 |
|
import static extra166y.Ops.*; |
11 |
|
import java.util.*; |
102 |
|
|
103 |
|
/** |
104 |
|
* Creates a new ParallelLongArray using the given executor and |
105 |
< |
* an array of the given size |
105 |
> |
* an array of the given size. |
106 |
|
* @param size the array size |
107 |
|
* @param executor the executor |
108 |
|
*/ |
195 |
|
} |
196 |
|
|
197 |
|
/** |
198 |
< |
* Returns the executor used for computations |
198 |
> |
* Returns the executor used for computations. |
199 |
|
* @return the executor |
200 |
|
*/ |
201 |
|
public ForkJoinPool getExecutor() { return ex; } |
202 |
|
|
203 |
|
/** |
204 |
< |
* Applies the given procedure to elements |
204 |
> |
* Applies the given procedure to elements. |
205 |
|
* @param procedure the procedure |
206 |
|
*/ |
207 |
|
public void apply(LongProcedure procedure) { |
209 |
|
} |
210 |
|
|
211 |
|
/** |
212 |
< |
* Returns reduction of elements |
212 |
> |
* Returns reduction of elements. |
213 |
|
* @param reducer the reducer |
214 |
|
* @param base the result for an empty array |
215 |
|
* @return reduction |
219 |
|
} |
220 |
|
|
221 |
|
/** |
222 |
< |
* Returns a new ParallelLongArray holding all elements |
222 |
> |
* Returns a new ParallelLongArray holding all elements. |
223 |
|
* @return a new ParallelLongArray holding all elements |
224 |
|
*/ |
225 |
|
public ParallelLongArray all() { |
250 |
|
|
251 |
|
/** |
252 |
|
* Replaces elements with the results of applying the given |
253 |
< |
* mapping to each index and current element value |
253 |
> |
* mapping to each index and current element value. |
254 |
|
* @param op the op |
255 |
|
* @return this (to simplify use in expressions) |
256 |
|
*/ |
263 |
|
* Replaces elements with the results of applying the given |
264 |
|
* generator. For example, to fill the array with uniform random |
265 |
|
* values, use |
266 |
< |
* <tt>replaceWithGeneratedValue(Ops.longRandom())</tt> |
266 |
> |
* {@code replaceWithGeneratedValue(Ops.longRandom())}. |
267 |
|
* @param generator the generator |
268 |
|
* @return this (to simplify use in expressions) |
269 |
|
*/ |
284 |
|
|
285 |
|
/** |
286 |
|
* Replaces elements with results of applying |
287 |
< |
* <tt>op(thisElement, otherElement)</tt> |
287 |
> |
* {@code op(thisElement, otherElement)}. |
288 |
|
* @param other the other array |
289 |
|
* @param combiner the combiner |
290 |
|
* @return this (to simplify use in expressions) |
298 |
|
|
299 |
|
/** |
300 |
|
* Replaces elements with results of applying |
301 |
< |
* <tt>op(thisElement, otherElement)</tt> |
301 |
> |
* {@code op(thisElement, otherElement)}. |
302 |
|
* @param other the other array |
303 |
|
* @param combiner the combiner |
304 |
|
* @return this (to simplify use in expressions) |
305 |
|
* @throws ArrayIndexOutOfBoundsException if other array has |
306 |
< |
* fewer elements than this array. |
306 |
> |
* fewer elements than this array |
307 |
|
*/ |
308 |
|
public ParallelLongArray replaceWithMapping(BinaryLongOp combiner, |
309 |
|
long[] other) { |
313 |
|
|
314 |
|
/** |
315 |
|
* Returns the index of some element equal to given target, or -1 |
316 |
< |
* if not present |
316 |
> |
* if not present. |
317 |
|
* @param target the element to search for |
318 |
|
* @return the index or -1 if not present |
319 |
|
*/ |
402 |
|
/** |
403 |
|
* Replaces each element with the running cumulation of applying |
404 |
|
* the given reducer. For example, if the contents are the numbers |
405 |
< |
* <tt>1, 2, 3</tt>, and the reducer operation adds numbers, then |
406 |
< |
* after invocation of this method, the contents would be <tt>1, |
407 |
< |
* 3, 6</tt> (that is, <tt>1, 1+2, 1+2+3</tt>); |
405 |
> |
* {@code 1, 2, 3}, and the reducer operation adds numbers, then |
406 |
> |
* after invocation of this method, the contents would be {@code 1, |
407 |
> |
* 3, 6} (that is, {@code 1, 1+2, 1+2+3}). |
408 |
|
* @param reducer the reducer |
409 |
|
* @param base the result for an empty array |
410 |
|
* @return this (to simplify use in expressions) |
417 |
|
/** |
418 |
|
* Replaces each element with the cumulation of applying the given |
419 |
|
* reducer to all previous values, and returns the total |
420 |
< |
* reduction. For example, if the contents are the numbers <tt>1, |
421 |
< |
* 2, 3</tt>, and the reducer operation adds numbers, then after |
422 |
< |
* invocation of this method, the contents would be <tt>0, 1, |
423 |
< |
* 3</tt> (that is, <tt>0, 0+1, 0+1+2</tt>, and the return value |
424 |
< |
* would be 6 (that is, <tt> 1+2+3</tt>); |
420 |
> |
* reduction. For example, if the contents are the numbers {@code 1, |
421 |
> |
* 2, 3}, and the reducer operation adds numbers, then after |
422 |
> |
* invocation of this method, the contents would be {@code 0, 1, |
423 |
> |
* 3} (that is, {@code 0, 0+1, 0+1+2}, and the return value |
424 |
> |
* would be 6 (that is, {@code 1+2+3}). |
425 |
|
* @param reducer the reducer |
426 |
|
* @param base the result for an empty array |
427 |
|
* @return the total reduction |
446 |
|
* Sorts the array, assuming all elements are Comparable. Unlike |
447 |
|
* Arrays.sort, this sort does not guarantee that elements |
448 |
|
* with equal keys maintain their relative position in the array. |
448 |
– |
* @throws ClassCastException if any element is not Comparable |
449 |
|
* @return this (to simplify use in expressions) |
450 |
+ |
* @throws ClassCastException if any element is not Comparable |
451 |
|
*/ |
452 |
|
public ParallelLongArray sort() { |
453 |
|
super.sort(); |
479 |
|
} |
480 |
|
|
481 |
|
/** |
482 |
< |
* Equivalent to <tt>asList().addAll</tt> but specialized for array |
482 |
> |
* Equivalent to {@code asList().addAll} but specialized for array |
483 |
|
* arguments and likely to be more efficient. |
484 |
|
* @param other the elements to add |
485 |
|
* @return this (to simplify use in expressions) |
836 |
|
* Returns an iterator stepping through each element of the array |
837 |
|
* up to the current limit. This iterator does <em>not</em> |
838 |
|
* support the remove operation. However, a full |
839 |
< |
* <tt>ListIterator</tt> supporting add, remove, and set |
839 |
> |
* {@code ListIterator} supporting add, remove, and set |
840 |
|
* operations is available via {@link #asList}. |
841 |
|
* @return an iterator stepping through each element |
842 |
|
*/ |
910 |
|
public void set(int i, long x) { array[i] = x; } |
911 |
|
|
912 |
|
/** |
913 |
< |
* Equivalent to <tt>asList().toString()</tt> |
913 |
> |
* Equivalent to {@code asList().toString()}. |
914 |
|
* @return a string representation |
915 |
|
*/ |
916 |
|
public String toString() { |