--- jsr166/src/extra166y/ParallelArray.java 2011/03/15 19:47:02 1.2 +++ jsr166/src/extra166y/ParallelArray.java 2012/12/30 02:05:53 1.8 @@ -22,7 +22,7 @@ import java.lang.reflect.Array; * matching a predicate or ranges of indices, and to reduce * all elements into a single value such as a sum. * - *

A ParallelArray is constructed by allocating, using, or copying + *

A ParallelArray is constructed by allocating, using, or copying * an array, using one of the static factory methods {@link #create}, * {@link #createEmpty}, {@link #createUsingHandoff} and {@link * #createFromCopy}. Upon construction, the encapsulated array managed @@ -31,7 +31,7 @@ import java.lang.reflect.Array; * array, access by another thread of an element of a ParallelArray * while another operation is in progress has undefined effects. * - *

The ForkJoinPool used to construct a ParallelArray can be + *

The ForkJoinPool used to construct a ParallelArray can be * shared safely by other threads (and used in other * ParallelArrays). To avoid the overhead associated with creating * multiple executors, it is often a good idea to use the {@link @@ -67,7 +67,7 @@ import java.lang.reflect.Array; * significantly improving performance beyond that of the Long and * Double versions.) * - *

Most usages of ParallelArray involve sets of operations prefixed + *

Most usages of ParallelArray involve sets of operations prefixed * with range bounds, filters, and mappings (including mappings that * combine elements from other ParallelArrays), using * withBounds, withFilter, and withMapping, @@ -139,7 +139,6 @@ import java.lang.reflect.Array; * static final GpaField gpaField = new GpaField(); * } * - * */ public class ParallelArray extends AbstractParallelAnyArray.OUPap implements Iterable { /* @@ -273,26 +272,26 @@ public class ParallelArray extends Ab * mapped ParallelArray. */ public static interface SummaryStatistics { - /** Return the number of elements */ + /** Returns the number of elements */ public int size(); - /** Return the minimum element, or null if empty */ + /** Returns the minimum element, or null if empty */ public T min(); - /** Return the maximum element, or null if empty */ + /** Returns the maximum element, or null if empty */ public T max(); - /** Return the index of the minimum element, or -1 if empty */ + /** Returns the index of the minimum element, or -1 if empty */ public int indexOfMin(); - /** Return the index of the maximum element, or -1 if empty */ + /** Returns the index of the maximum element, or -1 if empty */ public int indexOfMax(); } /** - * Returns the executor used for computations + * Returns the executor used for computations. * @return the executor */ public ForkJoinPool getExecutor() { return ex; } /** - * Applies the given procedure to elements + * Applies the given procedure to elements. * @param procedure the procedure */ public void apply(Procedure procedure) { @@ -300,7 +299,7 @@ public class ParallelArray extends Ab } /** - * Returns reduction of elements + * Returns reduction of elements. * @param reducer the reducer * @param base the result for an empty array * @return reduction @@ -310,7 +309,7 @@ public class ParallelArray extends Ab } /** - * Returns a new ParallelArray holding all elements + * Returns a new ParallelArray holding all elements. * @return a new ParallelArray holding all elements */ public ParallelArray all() { @@ -319,7 +318,7 @@ public class ParallelArray extends Ab /** * Returns a new ParallelArray with the given element type holding - * all elements + * all elements. * @param elementType the type of the elements * @return a new ParallelArray holding all elements */ @@ -353,7 +352,7 @@ public class ParallelArray extends Ab /** * Replaces elements with the results of applying the given - * mapping to each index and current element value + * mapping to each index and current element value. * @param op the op * @return this (to simplify use in expressions) */ @@ -387,7 +386,7 @@ public class ParallelArray extends Ab /** * Replaces elements with results of applying - * op(thisElement, otherElement) + * op(thisElement, otherElement). * @param other the other array * @param combiner the combiner * @return this (to simplify use in expressions) @@ -401,7 +400,7 @@ public class ParallelArray extends Ab /** * Replaces elements with results of applying - * op(thisElement, otherElement) + * op(thisElement, otherElement). * @param other the other array * @param combiner the combiner * @return this (to simplify use in expressions) @@ -414,7 +413,7 @@ public class ParallelArray extends Ab /** * Returns the index of some element equal to given target, - * or -1 if not present + * or -1 if not present. * @param target the element to search for * @return the index or -1 if not present */ @@ -451,7 +450,7 @@ public class ParallelArray extends Ab * to locate minimum and maximum elements. * @param comparator the comparator to use for * locating minimum and maximum elements - * @return the summary. + * @return the summary */ public ParallelArray.SummaryStatistics summary (Comparator comparator) { @@ -460,15 +459,15 @@ public class ParallelArray extends Ab /** * Returns summary statistics, assuming that all elements are - * Comparables - * @return the summary. + * Comparables. + * @return the summary */ public ParallelArray.SummaryStatistics summary() { return super.summary(); } /** - * Returns the minimum element, or null if empty + * Returns the minimum element, or null if empty. * @param comparator the comparator * @return minimum element, or null if empty */ @@ -478,16 +477,16 @@ public class ParallelArray extends Ab /** * Returns the minimum element, or null if empty, - * assuming that all elements are Comparables + * assuming that all elements are Comparables. * @return minimum element, or null if empty - * @throws ClassCastException if any element is not Comparable. + * @throws ClassCastException if any element is not Comparable */ public T min() { return super.min(); } /** - * Returns the maximum element, or null if empty + * Returns the maximum element, or null if empty. * @param comparator the comparator * @return maximum element, or null if empty */ @@ -496,10 +495,10 @@ public class ParallelArray extends Ab } /** - * Returns the maximum element, or null if empty - * assuming that all elements are Comparables + * Returns the maximum element, or null if empty, + * assuming that all elements are Comparables. * @return maximum element, or null if empty - * @throws ClassCastException if any element is not Comparable. + * @throws ClassCastException if any element is not Comparable */ public T max() { return super.max(); @@ -552,7 +551,7 @@ public class ParallelArray extends Ab * Sorts the array, assuming all elements are Comparable. Unlike * Arrays.sort, this sort does not guarantee that elements * with equal keys maintain their relative position in the array. - * @throws ClassCastException if any element is not Comparable. + * @throws ClassCastException if any element is not Comparable * @return this (to simplify use in expressions) */ public ParallelArray sort() { @@ -663,7 +662,7 @@ public class ParallelArray extends Ab * @param other the elements to add * @return this (to simplify use in expressions) */ - public ParallelArray addAll(T[] other) { + public ParallelArray addAll(T[] other) { int csize = other.length; int end = fence; insertSlotsAt(end, csize); @@ -716,7 +715,7 @@ public class ParallelArray extends Ab /** * Returns an operation prefix that causes a method to operate * only on the elements of the array for which the given selector - * returns true + * returns true. * @param selector the selector * @return operation prefix */ @@ -728,7 +727,7 @@ public class ParallelArray extends Ab /** * Returns an operation prefix that causes a method to operate * only on elements for which the given binary selector returns - * true + * true. * @param selector the selector * @return operation prefix */ @@ -741,7 +740,7 @@ public class ParallelArray extends Ab /** * Returns an operation prefix that causes a method to operate * only on elements for which the given indexed selector returns - * true + * true. * @param selector the selector * @return operation prefix */ @@ -790,7 +789,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithMapping withMapping (BinaryOp combiner, @@ -805,7 +804,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithMapping withMapping (ObjectAndDoubleToObject combiner, @@ -820,7 +819,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithMapping withMapping (ObjectAndLongToObject combiner, @@ -835,7 +834,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithDoubleMapping withMapping (ObjectAndObjectToDouble combiner, @@ -850,7 +849,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithDoubleMapping withMapping (ObjectAndDoubleToDouble combiner, @@ -865,7 +864,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithDoubleMapping withMapping (ObjectAndLongToDouble combiner, @@ -880,7 +879,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithLongMapping withMapping (ObjectAndObjectToLong combiner, @@ -895,7 +894,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithLongMapping withMapping (ObjectAndDoubleToLong combiner, @@ -910,7 +909,7 @@ public class ParallelArray extends Ab * @param other the other array * @return operation prefix * @throws IllegalArgumentException if other array is a - * filtered view (all filters must precede all mappings). + * filtered view (all filters must precede all mappings) */ public ParallelArrayWithLongMapping withMapping (ObjectAndLongToLong combiner, @@ -966,7 +965,7 @@ public class ParallelArray extends Ab * support the remove operation. However, a full * ListIterator supporting add, remove, and set * operations is available via {@link #asList}. - * @return an iterator stepping through each element. + * @return an iterator stepping through each element */ public Iterator iterator() { return new ParallelArrayIterator(array, fence); @@ -1018,21 +1017,21 @@ public class ParallelArray extends Ab public int size() { return fence; } /** - * Returns the element of the array at the given index + * Returns the element of the array at the given index. * @param i the index * @return the element of the array at the given index */ public T get(int i) { return array[i]; } /** - * Sets the element of the array at the given index to the given value + * Sets the element of the array at the given index to the given value. * @param i the index * @param x the value */ public void set(int i, T x) { array[i] = x; } /** - * Returns the underlying array used for computations + * Returns the underlying array used for computations. * @return the array */ public T[] getArray() { return array; } @@ -1053,7 +1052,7 @@ public class ParallelArray extends Ab * than the length of the underlying array, causes computations to * ignore elements past the given limit. * @param newLimit the new upper bound - * @throws IllegalArgumentException if newLimit less than zero. + * @throws IllegalArgumentException if newLimit less than zero */ public final void setLimit(int newLimit) { if (newLimit < 0) @@ -1096,7 +1095,7 @@ public class ParallelArray extends Ab } /** - * Make len slots available at index + * Makes len slots available at index. */ final void insertSlotsAt(int index, int len) { if (len <= 0)