291 |
|
public ForkJoinPool getExecutor() { return ex; } |
292 |
|
|
293 |
|
/** |
294 |
< |
* Applies the given procedure to elements |
294 |
> |
* Applies the given procedure to elements. |
295 |
|
* @param procedure the procedure |
296 |
|
*/ |
297 |
|
public void apply(Procedure<? super T> procedure) { |
299 |
|
} |
300 |
|
|
301 |
|
/** |
302 |
< |
* Returns reduction of elements |
302 |
> |
* Returns reduction of elements. |
303 |
|
* @param reducer the reducer |
304 |
|
* @param base the result for an empty array |
305 |
|
* @return reduction |
309 |
|
} |
310 |
|
|
311 |
|
/** |
312 |
< |
* Returns a new ParallelArray holding all elements |
312 |
> |
* Returns a new ParallelArray holding all elements. |
313 |
|
* @return a new ParallelArray holding all elements |
314 |
|
*/ |
315 |
|
public ParallelArray<T> all() { |
318 |
|
|
319 |
|
/** |
320 |
|
* Returns a new ParallelArray with the given element type holding |
321 |
< |
* all elements |
321 |
> |
* all elements. |
322 |
|
* @param elementType the type of the elements |
323 |
|
* @return a new ParallelArray holding all elements |
324 |
|
*/ |
352 |
|
|
353 |
|
/** |
354 |
|
* Replaces elements with the results of applying the given |
355 |
< |
* mapping to each index and current element value |
355 |
> |
* mapping to each index and current element value. |
356 |
|
* @param op the op |
357 |
|
* @return this (to simplify use in expressions) |
358 |
|
*/ |
386 |
|
|
387 |
|
/** |
388 |
|
* Replaces elements with results of applying |
389 |
< |
* <tt>op(thisElement, otherElement)</tt> |
389 |
> |
* <tt>op(thisElement, otherElement)</tt>. |
390 |
|
* @param other the other array |
391 |
|
* @param combiner the combiner |
392 |
|
* @return this (to simplify use in expressions) |
400 |
|
|
401 |
|
/** |
402 |
|
* Replaces elements with results of applying |
403 |
< |
* <tt>op(thisElement, otherElement)</tt> |
403 |
> |
* <tt>op(thisElement, otherElement)</tt>. |
404 |
|
* @param other the other array |
405 |
|
* @param combiner the combiner |
406 |
|
* @return this (to simplify use in expressions) |
413 |
|
|
414 |
|
/** |
415 |
|
* Returns the index of some element equal to given target, |
416 |
< |
* or -1 if not present |
416 |
> |
* or -1 if not present. |
417 |
|
* @param target the element to search for |
418 |
|
* @return the index or -1 if not present |
419 |
|
*/ |
450 |
|
* to locate minimum and maximum elements. |
451 |
|
* @param comparator the comparator to use for |
452 |
|
* locating minimum and maximum elements |
453 |
< |
* @return the summary. |
453 |
> |
* @return the summary |
454 |
|
*/ |
455 |
|
public ParallelArray.SummaryStatistics<T> summary |
456 |
|
(Comparator<? super T> comparator) { |
459 |
|
|
460 |
|
/** |
461 |
|
* Returns summary statistics, assuming that all elements are |
462 |
< |
* Comparables |
463 |
< |
* @return the summary. |
462 |
> |
* Comparables. |
463 |
> |
* @return the summary |
464 |
|
*/ |
465 |
|
public ParallelArray.SummaryStatistics<T> summary() { |
466 |
|
return super.summary(); |
467 |
|
} |
468 |
|
|
469 |
|
/** |
470 |
< |
* Returns the minimum element, or null if empty |
470 |
> |
* Returns the minimum element, or null if empty. |
471 |
|
* @param comparator the comparator |
472 |
|
* @return minimum element, or null if empty |
473 |
|
*/ |
477 |
|
|
478 |
|
/** |
479 |
|
* Returns the minimum element, or null if empty, |
480 |
< |
* assuming that all elements are Comparables |
480 |
> |
* assuming that all elements are Comparables. |
481 |
|
* @return minimum element, or null if empty |
482 |
< |
* @throws ClassCastException if any element is not Comparable. |
482 |
> |
* @throws ClassCastException if any element is not Comparable |
483 |
|
*/ |
484 |
|
public T min() { |
485 |
|
return super.min(); |
486 |
|
} |
487 |
|
|
488 |
|
/** |
489 |
< |
* Returns the maximum element, or null if empty |
489 |
> |
* Returns the maximum element, or null if empty. |
490 |
|
* @param comparator the comparator |
491 |
|
* @return maximum element, or null if empty |
492 |
|
*/ |
495 |
|
} |
496 |
|
|
497 |
|
/** |
498 |
< |
* Returns the maximum element, or null if empty |
499 |
< |
* assuming that all elements are Comparables |
498 |
> |
* Returns the maximum element, or null if empty, |
499 |
> |
* assuming that all elements are Comparables. |
500 |
|
* @return maximum element, or null if empty |
501 |
< |
* @throws ClassCastException if any element is not Comparable. |
501 |
> |
* @throws ClassCastException if any element is not Comparable |
502 |
|
*/ |
503 |
|
public T max() { |
504 |
|
return super.max(); |
551 |
|
* Sorts the array, assuming all elements are Comparable. Unlike |
552 |
|
* Arrays.sort, this sort does not guarantee that elements |
553 |
|
* with equal keys maintain their relative position in the array. |
554 |
< |
* @throws ClassCastException if any element is not Comparable. |
554 |
> |
* @throws ClassCastException if any element is not Comparable |
555 |
|
* @return this (to simplify use in expressions) |
556 |
|
*/ |
557 |
|
public ParallelArray<T> sort() { |
715 |
|
/** |
716 |
|
* Returns an operation prefix that causes a method to operate |
717 |
|
* only on the elements of the array for which the given selector |
718 |
< |
* returns true |
718 |
> |
* returns true. |
719 |
|
* @param selector the selector |
720 |
|
* @return operation prefix |
721 |
|
*/ |
727 |
|
/** |
728 |
|
* Returns an operation prefix that causes a method to operate |
729 |
|
* only on elements for which the given binary selector returns |
730 |
< |
* true |
730 |
> |
* true. |
731 |
|
* @param selector the selector |
732 |
|
* @return operation prefix |
733 |
|
*/ |
740 |
|
/** |
741 |
|
* Returns an operation prefix that causes a method to operate |
742 |
|
* only on elements for which the given indexed selector returns |
743 |
< |
* true |
743 |
> |
* true. |
744 |
|
* @param selector the selector |
745 |
|
* @return operation prefix |
746 |
|
*/ |
789 |
|
* @param other the other array |
790 |
|
* @return operation prefix |
791 |
|
* @throws IllegalArgumentException if other array is a |
792 |
< |
* filtered view (all filters must precede all mappings). |
792 |
> |
* filtered view (all filters must precede all mappings) |
793 |
|
*/ |
794 |
|
public <U,V,W> ParallelArrayWithMapping<T,V> withMapping |
795 |
|
(BinaryOp<? super T, ? super U, ? extends V> combiner, |
804 |
|
* @param other the other array |
805 |
|
* @return operation prefix |
806 |
|
* @throws IllegalArgumentException if other array is a |
807 |
< |
* filtered view (all filters must precede all mappings). |
807 |
> |
* filtered view (all filters must precede all mappings) |
808 |
|
*/ |
809 |
|
public <V> ParallelArrayWithMapping<T,V> withMapping |
810 |
|
(ObjectAndDoubleToObject<? super T, ? extends V> combiner, |
819 |
|
* @param other the other array |
820 |
|
* @return operation prefix |
821 |
|
* @throws IllegalArgumentException if other array is a |
822 |
< |
* filtered view (all filters must precede all mappings). |
822 |
> |
* filtered view (all filters must precede all mappings) |
823 |
|
*/ |
824 |
|
public <V> ParallelArrayWithMapping<T,V> withMapping |
825 |
|
(ObjectAndLongToObject<? super T, ? extends V> combiner, |
834 |
|
* @param other the other array |
835 |
|
* @return operation prefix |
836 |
|
* @throws IllegalArgumentException if other array is a |
837 |
< |
* filtered view (all filters must precede all mappings). |
837 |
> |
* filtered view (all filters must precede all mappings) |
838 |
|
*/ |
839 |
|
public <U,W> ParallelArrayWithDoubleMapping<T> withMapping |
840 |
|
(ObjectAndObjectToDouble<? super T, ? super U> combiner, |
849 |
|
* @param other the other array |
850 |
|
* @return operation prefix |
851 |
|
* @throws IllegalArgumentException if other array is a |
852 |
< |
* filtered view (all filters must precede all mappings). |
852 |
> |
* filtered view (all filters must precede all mappings) |
853 |
|
*/ |
854 |
|
public ParallelArrayWithDoubleMapping<T> withMapping |
855 |
|
(ObjectAndDoubleToDouble<? super T> combiner, |
864 |
|
* @param other the other array |
865 |
|
* @return operation prefix |
866 |
|
* @throws IllegalArgumentException if other array is a |
867 |
< |
* filtered view (all filters must precede all mappings). |
867 |
> |
* filtered view (all filters must precede all mappings) |
868 |
|
*/ |
869 |
|
public ParallelArrayWithDoubleMapping<T> withMapping |
870 |
|
(ObjectAndLongToDouble<? super T> combiner, |
879 |
|
* @param other the other array |
880 |
|
* @return operation prefix |
881 |
|
* @throws IllegalArgumentException if other array is a |
882 |
< |
* filtered view (all filters must precede all mappings). |
882 |
> |
* filtered view (all filters must precede all mappings) |
883 |
|
*/ |
884 |
|
public <U,W> ParallelArrayWithLongMapping<T> withMapping |
885 |
|
(ObjectAndObjectToLong<? super T, ? super U> combiner, |
894 |
|
* @param other the other array |
895 |
|
* @return operation prefix |
896 |
|
* @throws IllegalArgumentException if other array is a |
897 |
< |
* filtered view (all filters must precede all mappings). |
897 |
> |
* filtered view (all filters must precede all mappings) |
898 |
|
*/ |
899 |
|
public ParallelArrayWithLongMapping<T> withMapping |
900 |
|
(ObjectAndDoubleToLong<? super T> combiner, |
909 |
|
* @param other the other array |
910 |
|
* @return operation prefix |
911 |
|
* @throws IllegalArgumentException if other array is a |
912 |
< |
* filtered view (all filters must precede all mappings). |
912 |
> |
* filtered view (all filters must precede all mappings) |
913 |
|
*/ |
914 |
|
public ParallelArrayWithLongMapping<T> withMapping |
915 |
|
(ObjectAndLongToLong<? super T> combiner, |
965 |
|
* support the remove operation. However, a full |
966 |
|
* <tt>ListIterator</tt> supporting add, remove, and set |
967 |
|
* operations is available via {@link #asList}. |
968 |
< |
* @return an iterator stepping through each element. |
968 |
> |
* @return an iterator stepping through each element |
969 |
|
*/ |
970 |
|
public Iterator<T> iterator() { |
971 |
|
return new ParallelArrayIterator<T>(array, fence); |
1017 |
|
public int size() { return fence; } |
1018 |
|
|
1019 |
|
/** |
1020 |
< |
* Returns the element of the array at the given index |
1020 |
> |
* Returns the element of the array at the given index. |
1021 |
|
* @param i the index |
1022 |
|
* @return the element of the array at the given index |
1023 |
|
*/ |
1024 |
|
public T get(int i) { return array[i]; } |
1025 |
|
|
1026 |
|
/** |
1027 |
< |
* Sets the element of the array at the given index to the given value |
1027 |
> |
* Sets the element of the array at the given index to the given value. |
1028 |
|
* @param i the index |
1029 |
|
* @param x the value |
1030 |
|
*/ |
1031 |
|
public void set(int i, T x) { array[i] = x; } |
1032 |
|
|
1033 |
|
/** |
1034 |
< |
* Returns the underlying array used for computations |
1034 |
> |
* Returns the underlying array used for computations. |
1035 |
|
* @return the array |
1036 |
|
*/ |
1037 |
|
public T[] getArray() { return array; } |
1052 |
|
* than the length of the underlying array, causes computations to |
1053 |
|
* ignore elements past the given limit. |
1054 |
|
* @param newLimit the new upper bound |
1055 |
< |
* @throws IllegalArgumentException if newLimit less than zero. |
1055 |
> |
* @throws IllegalArgumentException if newLimit less than zero |
1056 |
|
*/ |
1057 |
|
public final void setLimit(int newLimit) { |
1058 |
|
if (newLimit < 0) |