ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/extra166y/ParallelLongArray.java
(Generate patch)

Comparing jsr166/src/extra166y/ParallelLongArray.java (file contents):
Revision 1.5 by jsr166, Tue Feb 21 01:54:03 2012 UTC vs.
Revision 1.10 by jsr166, Wed Jan 16 00:51:11 2013 UTC

# Line 46 | Line 46 | import java.lang.reflect.Array;
46   *     public long op(int i) { return i + 2; } };
47   *   static LongPredicate notDivisibleBy(final long p) {
48   *     return new LongPredicate() {
49 < *        public boolean op(long n) { return n &lt;= p || (n % p) != 0; }
49 > *       public boolean op(long n) { return n &lt;= p || (n % p) != 0; }
50   *     }; }
51   *   static LongPredicate notProbablePrime = new LongPredicate() {
52   *     private static final int CERTAINTY = 8;
# Line 101 | Line 101 | public class ParallelLongArray extends A
101  
102      /**
103       * Creates a new ParallelLongArray using the given executor and
104 <     * an array of the given size
104 >     * an array of the given size.
105       * @param size the array size
106       * @param executor the executor
107       */
# Line 194 | Line 194 | public class ParallelLongArray extends A
194      }
195  
196      /**
197 <     * Returns the executor used for computations
197 >     * Returns the executor used for computations.
198       * @return the executor
199       */
200      public ForkJoinPool getExecutor() { return ex; }
201  
202      /**
203 <     * Applies the given procedure to elements
203 >     * Applies the given procedure to elements.
204       * @param procedure the procedure
205       */
206      public void apply(LongProcedure procedure) {
# Line 208 | Line 208 | public class ParallelLongArray extends A
208      }
209  
210      /**
211 <     * Returns reduction of elements
211 >     * Returns reduction of elements.
212       * @param reducer the reducer
213       * @param base the result for an empty array
214       * @return reduction
# Line 218 | Line 218 | public class ParallelLongArray extends A
218      }
219  
220      /**
221 <     * Returns a new ParallelLongArray holding all elements
221 >     * Returns a new ParallelLongArray holding all elements.
222       * @return a new ParallelLongArray holding all elements
223       */
224      public ParallelLongArray all() {
# Line 249 | Line 249 | public class ParallelLongArray extends A
249  
250      /**
251       * Replaces elements with the results of applying the given
252 <     * mapping to each index and current element value
252 >     * mapping to each index and current element value.
253       * @param op the op
254       * @return this (to simplify use in expressions)
255       */
# Line 262 | Line 262 | public class ParallelLongArray extends A
262       * Replaces elements with the results of applying the given
263       * generator. For example, to fill the array with uniform random
264       * values, use
265 <     * <tt>replaceWithGeneratedValue(Ops.longRandom())</tt>
265 >     * {@code replaceWithGeneratedValue(Ops.longRandom())}.
266       * @param generator the generator
267       * @return this (to simplify use in expressions)
268       */
# Line 283 | Line 283 | public class ParallelLongArray extends A
283  
284      /**
285       * Replaces elements with results of applying
286 <     * <tt>op(thisElement, otherElement)</tt>
286 >     * {@code op(thisElement, otherElement)}.
287       * @param other the other array
288       * @param combiner the combiner
289       * @return this (to simplify use in expressions)
# Line 297 | Line 297 | public class ParallelLongArray extends A
297  
298      /**
299       * Replaces elements with results of applying
300 <     * <tt>op(thisElement, otherElement)</tt>
300 >     * {@code op(thisElement, otherElement)}.
301       * @param other the other array
302       * @param combiner the combiner
303       * @return this (to simplify use in expressions)
# Line 312 | Line 312 | public class ParallelLongArray extends A
312  
313      /**
314       * Returns the index of some element equal to given target, or -1
315 <     * if not present
315 >     * if not present.
316       * @param target the element to search for
317       * @return the index or -1 if not present
318       */
# Line 349 | Line 349 | public class ParallelLongArray extends A
349       * to locate minimum and maximum elements.
350       * @param comparator the comparator to use for
351       * locating minimum and maximum elements
352 <     * @return the summary.
352 >     * @return the summary
353       */
354      public ParallelLongArray.SummaryStatistics summary
355          (LongComparator comparator) {
# Line 357 | Line 357 | public class ParallelLongArray extends A
357      }
358  
359      /**
360 <     * Returns summary statistics, using natural comparator
361 <     * @return the summary.
360 >     * Returns summary statistics, using natural comparator.
361 >     * @return the summary
362       */
363      public ParallelLongArray.SummaryStatistics summary() {
364          return super.summary();
365      }
366  
367      /**
368 <     * Returns the minimum element, or Long.MAX_VALUE if empty
368 >     * Returns the minimum element, or Long.MAX_VALUE if empty.
369       * @param comparator the comparator
370       * @return minimum element, or Long.MAX_VALUE if empty
371       */
# Line 374 | Line 374 | public class ParallelLongArray extends A
374      }
375  
376      /**
377 <     * Returns the minimum element, or Long.MAX_VALUE if empty,
377 >     * Returns the minimum element, or Long.MAX_VALUE if empty.
378       * @return minimum element, or Long.MAX_VALUE if empty
379       */
380      public long min() {
# Line 382 | Line 382 | public class ParallelLongArray extends A
382      }
383  
384      /**
385 <     * Returns the maximum element, or Long.MIN_VALUE if empty
385 >     * Returns the maximum element, or Long.MIN_VALUE if empty.
386       * @param comparator the comparator
387       * @return maximum element, or Long.MIN_VALUE if empty
388       */
# Line 391 | Line 391 | public class ParallelLongArray extends A
391      }
392  
393      /**
394 <     * Returns the maximum element, or Long.MIN_VALUE if empty
394 >     * Returns the maximum element, or Long.MIN_VALUE if empty.
395       * @return maximum element, or Long.MIN_VALUE if empty
396       */
397      public long max() {
# Line 401 | Line 401 | public class ParallelLongArray extends A
401      /**
402       * Replaces each element with the running cumulation of applying
403       * the given reducer. For example, if the contents are the numbers
404 <     * <tt>1, 2, 3</tt>, and the reducer operation adds numbers, then
405 <     * after invocation of this method, the contents would be <tt>1,
406 <     * 3, 6</tt> (that is, <tt>1, 1+2, 1+2+3</tt>);
404 >     * {@code 1, 2, 3}, and the reducer operation adds numbers, then
405 >     * after invocation of this method, the contents would be {@code 1,
406 >     * 3, 6} (that is, {@code 1, 1+2, 1+2+3});
407       * @param reducer the reducer
408       * @param base the result for an empty array
409       * @return this (to simplify use in expressions)
# Line 416 | Line 416 | public class ParallelLongArray extends A
416      /**
417       * Replaces each element with the cumulation of applying the given
418       * reducer to all previous values, and returns the total
419 <     * reduction. For example, if the contents are the numbers <tt>1,
420 <     * 2, 3</tt>, and the reducer operation adds numbers, then after
421 <     * invocation of this method, the contents would be <tt>0, 1,
422 <     * 3</tt> (that is, <tt>0, 0+1, 0+1+2</tt>, and the return value
423 <     * would be 6 (that is, <tt> 1+2+3</tt>);
419 >     * reduction. For example, if the contents are the numbers {@code 1,
420 >     * 2, 3}, and the reducer operation adds numbers, then after
421 >     * invocation of this method, the contents would be {@code 0, 1,
422 >     * 3} (that is, {@code 0, 0+1, 0+1+2}, and the return value
423 >     * would be 6 (that is, {@code  1+2+3});
424       * @param reducer the reducer
425       * @param base the result for an empty array
426       * @return the total reduction
# Line 445 | Line 445 | public class ParallelLongArray extends A
445       * Sorts the array, assuming all elements are Comparable. Unlike
446       * Arrays.sort, this sort does not guarantee that elements
447       * with equal keys maintain their relative position in the array.
448 <     * @throws ClassCastException if any element is not Comparable.
448 >     * @throws ClassCastException if any element is not Comparable
449       * @return this (to simplify use in expressions)
450       */
451      public ParallelLongArray sort() {
# Line 478 | Line 478 | public class ParallelLongArray extends A
478      }
479  
480      /**
481 <     * Equivalent to <tt>asList().addAll</tt> but specialized for array
481 >     * Equivalent to {@code asList().addAll} but specialized for array
482       * arguments and likely to be more efficient.
483       * @param other the elements to add
484       * @return this (to simplify use in expressions)
# Line 552 | Line 552 | public class ParallelLongArray extends A
552      }
553  
554      /**
555 <     * Returns the sum of elements
555 >     * Returns the sum of elements.
556       * @return the sum of elements
557       */
558      public long sum() {
# Line 560 | Line 560 | public class ParallelLongArray extends A
560      }
561  
562      /**
563 <     * Replaces each element with the running sum
563 >     * Replaces each element with the running sum.
564       * @return this (to simplify use in expressions)
565       */
566      public ParallelLongArray cumulateSum() {
# Line 569 | Line 569 | public class ParallelLongArray extends A
569      }
570  
571      /**
572 <     * Replaces each element with its prefix sum
572 >     * Replaces each element with its prefix sum.
573       * @return the total sum
574       */
575      public long precumulateSum() {
# Line 592 | Line 592 | public class ParallelLongArray extends A
592      /**
593       * Returns an operation prefix that causes a method to operate
594       * only on the elements of the array for which the given selector
595 <     * returns true
595 >     * returns true.
596       * @param selector the selector
597       * @return operation prefix
598       */
# Line 603 | Line 603 | public class ParallelLongArray extends A
603      /**
604       * Returns an operation prefix that causes a method to operate
605       * only on elements for which the given binary selector returns
606 <     * true
606 >     * true.
607       * @param selector the selector
608       * @return operation prefix
609       */
# Line 616 | Line 616 | public class ParallelLongArray extends A
616      /**
617       * Returns an operation prefix that causes a method to operate
618       * only on elements for which the given indexed selector returns
619 <     * true
619 >     * true.
620       * @param selector the selector
621       * @return operation prefix
622       */
# Line 664 | Line 664 | public class ParallelLongArray extends A
664       * @param other the other array
665       * @return operation prefix
666       * @throws IllegalArgumentException if other array is a
667 <     * filtered view (all filters must precede all mappings).
667 >     * filtered view (all filters must precede all mappings)
668       */
669      public <V,W,X> ParallelLongArrayWithMapping<W> withMapping
670          (LongAndObjectToObject<? super V, ? extends W> combiner,
# Line 679 | Line 679 | public class ParallelLongArray extends A
679       * @param other the other array
680       * @return operation prefix
681       * @throws IllegalArgumentException if other array is a
682 <     * filtered view (all filters must precede all mappings).
682 >     * filtered view (all filters must precede all mappings)
683       */
684      public <V> ParallelLongArrayWithMapping<V> withMapping
685          (LongAndDoubleToObject<? extends V> combiner,
# Line 694 | Line 694 | public class ParallelLongArray extends A
694       * @param other the other array
695       * @return operation prefix
696       * @throws IllegalArgumentException if other array is a
697 <     * filtered view (all filters must precede all mappings).
697 >     * filtered view (all filters must precede all mappings)
698       */
699      public <V> ParallelLongArrayWithMapping<V> withMapping
700          (LongAndLongToObject<? extends V> combiner,
# Line 709 | Line 709 | public class ParallelLongArray extends A
709       * @param other the other array
710       * @return operation prefix
711       * @throws IllegalArgumentException if other array is a
712 <     * filtered view (all filters must precede all mappings).
712 >     * filtered view (all filters must precede all mappings)
713       */
714      public <V,W> ParallelLongArrayWithDoubleMapping withMapping
715          (LongAndObjectToDouble<? super V> combiner,
# Line 724 | Line 724 | public class ParallelLongArray extends A
724       * @param other the other array
725       * @return operation prefix
726       * @throws IllegalArgumentException if other array is a
727 <     * filtered view (all filters must precede all mappings).
727 >     * filtered view (all filters must precede all mappings)
728       */
729      public ParallelLongArrayWithDoubleMapping withMapping
730          (LongAndDoubleToDouble combiner,
# Line 739 | Line 739 | public class ParallelLongArray extends A
739       * @param other the other array
740       * @return operation prefix
741       * @throws IllegalArgumentException if other array is a
742 <     * filtered view (all filters must precede all mappings).
742 >     * filtered view (all filters must precede all mappings)
743       */
744      public ParallelLongArrayWithDoubleMapping withMapping
745          (LongAndLongToDouble combiner,
# Line 754 | Line 754 | public class ParallelLongArray extends A
754       * @param other the other array
755       * @return operation prefix
756       * @throws IllegalArgumentException if other array is a
757 <     * filtered view (all filters must precede all mappings).
757 >     * filtered view (all filters must precede all mappings)
758       */
759      public <V,W> ParallelLongArrayWithLongMapping withMapping
760          (LongAndObjectToLong<? super V> combiner,
# Line 769 | Line 769 | public class ParallelLongArray extends A
769       * @param other the other array
770       * @return operation prefix
771       * @throws IllegalArgumentException if other array is a
772 <     * filtered view (all filters must precede all mappings).
772 >     * filtered view (all filters must precede all mappings)
773       */
774      public ParallelLongArrayWithLongMapping withMapping
775          (LongAndDoubleToLong combiner,
# Line 784 | Line 784 | public class ParallelLongArray extends A
784       * @param other the other array
785       * @return operation prefix
786       * @throws IllegalArgumentException if other array is a
787 <     * filtered view (all filters must precede all mappings).
787 >     * filtered view (all filters must precede all mappings)
788       */
789      public ParallelLongArrayWithLongMapping withMapping
790          (BinaryLongOp combiner,
# Line 835 | Line 835 | public class ParallelLongArray extends A
835       * Returns an iterator stepping through each element of the array
836       * up to the current limit. This iterator does <em>not</em>
837       * support the remove operation. However, a full
838 <     * <tt>ListIterator</tt> supporting add, remove, and set
838 >     * {@code ListIterator} supporting add, remove, and set
839       * operations is available via {@link #asList}.
840 <     * @return an iterator stepping through each element.
840 >     * @return an iterator stepping through each element
841       */
842      public Iterator<Long> iterator() {
843          return new ParallelLongArrayIterator(array, fence);
# Line 889 | Line 889 | public class ParallelLongArray extends A
889      public int size() { return fence; }
890  
891      /**
892 <     * Returns the underlying array used for computations
892 >     * Returns the underlying array used for computations.
893       * @return the array
894       */
895      public long[] getArray() { return array; }
896  
897      /**
898 <     * Returns the element of the array at the given index
898 >     * Returns the element of the array at the given index.
899       * @param i the index
900       * @return the element of the array at the given index
901       */
902      public long get(int i) { return array[i]; }
903  
904      /**
905 <     * Sets the element of the array at the given index to the given value
905 >     * Sets the element of the array at the given index to the given value.
906       * @param i the index
907       * @param x the value
908       */
909      public void set(int i, long x) { array[i] = x; }
910  
911      /**
912 <     * Equivalent to <tt>asList().toString()</tt>
912 >     * Equivalent to {@code asList().toString()}
913       * @return a string representation
914       */
915      public String toString() {
# Line 923 | Line 923 | public class ParallelLongArray extends A
923       * than the length of the underlying array, causes computations to
924       * ignore elements past the given limit.
925       * @param newLimit the new upper bound
926 <     * @throws IllegalArgumentException if newLimit less than zero.
926 >     * @throws IllegalArgumentException if newLimit less than zero
927       */
928      public final void setLimit(int newLimit) {
929          if (newLimit < 0)
# Line 1207 | Line 1207 | public class ParallelLongArray extends A
1207      }
1208  
1209   }
1210

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines