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

Comparing jsr166/src/extra166y/AbstractParallelAnyArray.java (file contents):
Revision 1.10 by jsr166, Tue Feb 21 01:54:03 2012 UTC vs.
Revision 1.18 by jsr166, Sun Jan 18 20:17:32 2015 UTC

# Line 5 | Line 5
5   */
6  
7   package extra166y;
8 +
9   import jsr166y.*;
10   import static extra166y.Ops.*;
11   import java.util.*;
# Line 82 | Line 83 | public abstract class AbstractParallelAn
83      /**
84       * Returns the index of some element matching bound and filter
85       * constraints, or -1 if none.
86 <     * @return index of matching element, or -1 if none.
86 >     * @return index of matching element, or -1 if none
87       */
88      public int anyIndex() {
89          if (!hasFilter())
# Line 95 | Line 96 | public abstract class AbstractParallelAn
96      }
97  
98      /**
99 <     * Returns true if there are no elements
99 >     * Returns true if there are no elements.
100       * @return true if there are no elements
101       */
102      public boolean isEmpty() {
# Line 132 | Line 133 | public abstract class AbstractParallelAn
133       */
134      Object[] ogetArray() { return null; }
135      double[] dgetArray() { return null; }
136 <    long[]  lgetArray() { return null; }
136 >    long[]   lgetArray() { return null; }
137      abstract Object oget(int index);
138      abstract double dget(int index);
139      abstract long lget(int index);
# Line 145 | Line 146 | public abstract class AbstractParallelAn
146       * oget, dget, etc. But most are overridden in most concrete
147       * classes to avoid per-element dispatching.
148       */
149 +
150      void leafApply(int lo, int hi, Procedure procedure) {
151          for (int i = lo; i < hi; ++i)
152              if (isSelected(i))
# Line 274 | Line 276 | public abstract class AbstractParallelAn
276      /**
277       * Shared support for select/map all -- probe filter, map, and
278       * type to start selection driver, or do parallel mapping, or
279 <     * just copy,
279 >     * just copy.
280       */
281      final Object[] allObjects(Class elementType) {
282          if (hasFilter()) {
# Line 403 | Line 405 | public abstract class AbstractParallelAn
405                              int otherOffset, BinaryLongOp combiner) {}
406  
407      // Base of object ref array classes
408 <    static abstract class OPap<T> extends AbstractParallelAnyArray {
408 >    abstract static class OPap<T> extends AbstractParallelAnyArray {
409          T[] array;
410          OPap(ForkJoinPool ex, int origin, int fence, T[] array) {
411              super(ex, origin, fence);
# Line 433 | Line 435 | public abstract class AbstractParallelAn
435      }
436  
437      // Base of double array classes
438 <    static abstract class DPap extends AbstractParallelAnyArray {
438 >    abstract static class DPap extends AbstractParallelAnyArray {
439          double[] array;
440          DPap(ForkJoinPool ex, int origin, int fence, double[] array) {
441              super(ex, origin, fence);
# Line 463 | Line 465 | public abstract class AbstractParallelAn
465      }
466  
467      // Base of long array classes
468 <    static abstract class LPap extends AbstractParallelAnyArray {
468 >    abstract static class LPap extends AbstractParallelAnyArray {
469          long[] array;
470          LPap(ForkJoinPool ex, int origin, int fence, long[] array) {
471              super(ex, origin, fence);
# Line 513 | Line 515 | public abstract class AbstractParallelAn
515              return new ORPap<T>(ex, origin, fence, array, selector);
516          }
517  
518 <        public <U> ParallelArrayWithMapping<T, U> withMapping
518 >        public <U> ParallelArrayWithMapping<T,U> withMapping
519              (Op<? super T, ? extends U> op) {
520              return new OUOMPap<T,U>(ex, origin, fence, array, op);
521          }
# Line 1169 | Line 1171 | public abstract class AbstractParallelAn
1171                   compoundIndexedSelector(this.selector, selector));
1172          }
1173  
1174 <        public <U> ParallelArrayWithMapping<T, U> withMapping
1174 >        public <U> ParallelArrayWithMapping<T,U> withMapping
1175              (Op<? super T, ? extends U> op) {
1176              return new OFOMPap<T,U>(ex, origin, fence, array, selector, op);
1177          }
# Line 1710 | Line 1712 | public abstract class AbstractParallelAn
1712                   compoundIndexedSelector(this.selector, selector));
1713          }
1714  
1715 <        public <U> ParallelArrayWithMapping<T, U> withMapping
1715 >        public <U> ParallelArrayWithMapping<T,U> withMapping
1716              (Op<? super T, ? extends U> op) {
1717              return new OROMPap<T,U>(ex, origin, fence, array, selector, op);
1718          }
# Line 2228 | Line 2230 | public abstract class AbstractParallelAn
2230  
2231      // Object-mapped
2232  
2233 <    static abstract class OOMPap<T,U> extends ParallelArrayWithMapping<T,U> {
2233 >    abstract static class OOMPap<T,U> extends ParallelArrayWithMapping<T,U> {
2234          final Op<? super T, ? extends U> op;
2235          OOMPap(ForkJoinPool ex, int origin, int fence,
2236                 T[] array,
# Line 2258 | Line 2260 | public abstract class AbstractParallelAn
2260          }
2261      }
2262  
2263 <    static abstract class DOMPap<U> extends ParallelDoubleArrayWithMapping<U> {
2263 >    abstract static class DOMPap<U> extends ParallelDoubleArrayWithMapping<U> {
2264          final DoubleToObject<? extends U> op;
2265          DOMPap(ForkJoinPool ex, int origin, int fence,
2266                 double[] array, DoubleToObject<? extends U> op) {
# Line 2287 | Line 2289 | public abstract class AbstractParallelAn
2289          }
2290      }
2291  
2292 <    static abstract class LOMPap<U> extends ParallelLongArrayWithMapping<U> {
2292 >    abstract static class LOMPap<U> extends ParallelLongArrayWithMapping<U> {
2293          final LongToObject<? extends U> op;
2294          LOMPap(ForkJoinPool ex, int origin, int fence,
2295                 long[] array, LongToObject<? extends U> op) {
# Line 2324 | Line 2326 | public abstract class AbstractParallelAn
2326              super(ex, origin, fence, array, op);
2327          }
2328  
2329 <        public <V> ParallelArrayWithMapping<T, V> withMapping
2329 >        public <V> ParallelArrayWithMapping<T,V> withMapping
2330              (Op<? super U, ? extends V> op) {
2331              return new OUOMPap<T,V>(ex, origin, fence, array,
2332                                      CommonOps.compoundOp(this.op, op));
# Line 2518 | Line 2520 | public abstract class AbstractParallelAn
2520          boolean hasFilter() { return true; }
2521          boolean isSelected(int i) { return selector.op(this.array[i]); }
2522  
2523 <        public <V> ParallelArrayWithMapping<T, V> withMapping
2523 >        public <V> ParallelArrayWithMapping<T,V> withMapping
2524              (Op<? super U, ? extends V> op) {
2525              return new OFOMPap<T,V>
2526                  (ex, origin, fence, array, selector,
# Line 2773 | Line 2775 | public abstract class AbstractParallelAn
2775          boolean hasFilter() { return true; }
2776          boolean isSelected(int i) { return selector.op(i, this.array[i]); }
2777  
2778 <        public <V> ParallelArrayWithMapping<T, V> withMapping
2778 >        public <V> ParallelArrayWithMapping<T,V> withMapping
2779              (Op<? super U, ? extends V> op) {
2780              return new OROMPap<T,V>
2781                  (ex, origin, fence, array, selector,
# Line 3013 | Line 3015 | public abstract class AbstractParallelAn
3015  
3016      // Object-combined
3017  
3018 <    static abstract class OOCPap<T,U> extends ParallelArrayWithMapping<T,U> {
3018 >    abstract static class OOCPap<T,U> extends ParallelArrayWithMapping<T,U> {
3019          final IntAndObjectToObject<? super T, ? extends U> op;
3020          OOCPap(ForkJoinPool ex, int origin, int fence,
3021                 T[] array,
# Line 3045 | Line 3047 | public abstract class AbstractParallelAn
3047          }
3048      }
3049  
3050 <    static abstract class DOCPap<U> extends ParallelDoubleArrayWithMapping<U> {
3050 >    abstract static class DOCPap<U> extends ParallelDoubleArrayWithMapping<U> {
3051          final IntAndDoubleToObject<? extends U> op;
3052          DOCPap(ForkJoinPool ex, int origin, int fence,
3053                 double[] array, IntAndDoubleToObject<? extends U> op) {
# Line 3076 | Line 3078 | public abstract class AbstractParallelAn
3078          }
3079      }
3080  
3081 <    static abstract class LOCPap<U> extends ParallelLongArrayWithMapping<U> {
3081 >    abstract static class LOCPap<U> extends ParallelLongArrayWithMapping<U> {
3082          final IntAndLongToObject<? extends U> op;
3083          LOCPap(ForkJoinPool ex, int origin, int fence,
3084                 long[] array, IntAndLongToObject<? extends U> op) {
# Line 3115 | Line 3117 | public abstract class AbstractParallelAn
3117              super(ex, origin, fence, array, op);
3118          }
3119  
3120 <        public <V> ParallelArrayWithMapping<T, V> withMapping
3120 >        public <V> ParallelArrayWithMapping<T,V> withMapping
3121              (Op<? super U, ? extends V> op) {
3122              return new OUOCPap<T,V>(ex, origin, fence, array,
3123                                      compoundIndexedOp(this.op, op));
# Line 3309 | Line 3311 | public abstract class AbstractParallelAn
3311          boolean hasFilter() { return true; }
3312          boolean isSelected(int i) { return selector.op(this.array[i]); }
3313  
3314 <        public <V> ParallelArrayWithMapping<T, V> withMapping
3314 >        public <V> ParallelArrayWithMapping<T,V> withMapping
3315              (Op<? super U, ? extends V> op) {
3316              return new OFOCPap<T,V>(ex, origin, fence, array, selector,
3317                                      compoundIndexedOp(this.op, op));
# Line 3552 | Line 3554 | public abstract class AbstractParallelAn
3554          boolean hasFilter() { return true; }
3555          boolean isSelected(int i) { return selector.op(i, this.array[i]); }
3556  
3557 <        public <V> ParallelArrayWithMapping<T, V> withMapping
3557 >        public <V> ParallelArrayWithMapping<T,V> withMapping
3558              (Op<? super U, ? extends V> op) {
3559              return new OROCPap<T,V>(ex, origin, fence, array, selector,
3560                                      compoundIndexedOp(this.op, op));
# Line 3784 | Line 3786 | public abstract class AbstractParallelAn
3786  
3787      // Double-mapped
3788  
3789 <    static abstract class ODMPap<T> extends ParallelArrayWithDoubleMapping<T> {
3789 >    abstract static class ODMPap<T> extends ParallelArrayWithDoubleMapping<T> {
3790          final ObjectToDouble<? super T> op;
3791          ODMPap(ForkJoinPool ex, int origin, int fence,
3792                 T[] array, ObjectToDouble<? super T> op) {
# Line 3814 | Line 3816 | public abstract class AbstractParallelAn
3816  
3817      }
3818  
3819 <    static abstract class DDMPap extends ParallelDoubleArrayWithDoubleMapping {
3819 >    abstract static class DDMPap extends ParallelDoubleArrayWithDoubleMapping {
3820          final DoubleOp op;
3821          DDMPap
3822              (ForkJoinPool ex, int origin, int fence,
# Line 3844 | Line 3846 | public abstract class AbstractParallelAn
3846          }
3847      }
3848  
3849 <    static abstract class LDMPap extends ParallelLongArrayWithDoubleMapping {
3849 >    abstract static class LDMPap extends ParallelLongArrayWithDoubleMapping {
3850          final LongToDouble op;
3851          LDMPap(ForkJoinPool ex, int origin, int fence,
3852                 long[] array, LongToDouble op) {
# Line 3892 | Line 3894 | public abstract class AbstractParallelAn
3894                                    CommonOps.compoundOp(this.op, op));
3895          }
3896  
3897 <        public <U> ParallelArrayWithMapping<T, U> withMapping
3897 >        public <U> ParallelArrayWithMapping<T,U> withMapping
3898              (DoubleToObject<? extends U> op) {
3899              return new OUOMPap<T,U>(ex, origin, fence, array,
3900                                      CommonOps.compoundOp(this.op, op));
# Line 4080 | Line 4082 | public abstract class AbstractParallelAn
4082                                    CommonOps.compoundOp(this.op, op));
4083          }
4084  
4085 <        public <U> ParallelArrayWithMapping<T, U> withMapping
4085 >        public <U> ParallelArrayWithMapping<T,U> withMapping
4086              (DoubleToObject<? extends U> op) {
4087              return new OFOMPap<T,U>(ex, origin, fence, array, selector,
4088                                      CommonOps.compoundOp(this.op, op));
# Line 4316 | Line 4318 | public abstract class AbstractParallelAn
4318                                    CommonOps.compoundOp(this.op, op));
4319          }
4320  
4321 <        public <U> ParallelArrayWithMapping<T, U> withMapping
4321 >        public <U> ParallelArrayWithMapping<T,U> withMapping
4322              (DoubleToObject<? extends U> op) {
4323              return new OROMPap<T,U>(ex, origin, fence, array, selector,
4324                                      CommonOps.compoundOp(this.op, op));
# Line 4530 | Line 4532 | public abstract class AbstractParallelAn
4532      }
4533  
4534      // double-combined
4535 <    static abstract class ODCPap<T> extends ParallelArrayWithDoubleMapping<T> {
4535 >    abstract static class ODCPap<T> extends ParallelArrayWithDoubleMapping<T> {
4536          final IntAndObjectToDouble<? super T> op;
4537          ODCPap(ForkJoinPool ex, int origin, int fence,
4538                 T[] array, IntAndObjectToDouble<? super T> op) {
# Line 4562 | Line 4564 | public abstract class AbstractParallelAn
4564  
4565      }
4566  
4567 <    static abstract class DDCPap extends ParallelDoubleArrayWithDoubleMapping {
4567 >    abstract static class DDCPap extends ParallelDoubleArrayWithDoubleMapping {
4568          final IntAndDoubleToDouble op;
4569          DDCPap(ForkJoinPool ex, int origin, int fence,
4570                 double[] array, IntAndDoubleToDouble op) {
# Line 4593 | Line 4595 | public abstract class AbstractParallelAn
4595          }
4596      }
4597  
4598 <    static abstract class LDCPap extends ParallelLongArrayWithDoubleMapping {
4598 >    abstract static class LDCPap extends ParallelLongArrayWithDoubleMapping {
4599          final IntAndLongToDouble op;
4600          LDCPap(ForkJoinPool ex, int origin, int fence,
4601                 long[] array, IntAndLongToDouble op) {
# Line 4641 | Line 4643 | public abstract class AbstractParallelAn
4643                                    compoundIndexedOp(this.op, op));
4644          }
4645  
4646 <        public <U> ParallelArrayWithMapping<T, U> withMapping
4646 >        public <U> ParallelArrayWithMapping<T,U> withMapping
4647              (DoubleToObject<? extends U> op) {
4648              return new OUOCPap<T,U>(ex, origin, fence, array,
4649                                      compoundIndexedOp(this.op, op));
# Line 4828 | Line 4830 | public abstract class AbstractParallelAn
4830                                    compoundIndexedOp(this.op, op));
4831          }
4832  
4833 <        public <U> ParallelArrayWithMapping<T, U> withMapping
4833 >        public <U> ParallelArrayWithMapping<T,U> withMapping
4834              (DoubleToObject<? extends U> op) {
4835              return new OFOCPap<T,U>(ex, origin, fence, array, selector,
4836                                      compoundIndexedOp(this.op, op));
# Line 5066 | Line 5068 | public abstract class AbstractParallelAn
5068                                    compoundIndexedOp(this.op, op));
5069          }
5070  
5071 <        public <U> ParallelArrayWithMapping<T, U> withMapping
5071 >        public <U> ParallelArrayWithMapping<T,U> withMapping
5072              (DoubleToObject<? extends U> op) {
5073              return new OROCPap<T,U>(ex, origin, fence, array, selector,
5074                                      compoundIndexedOp(this.op, op));
# Line 5281 | Line 5283 | public abstract class AbstractParallelAn
5283      }
5284  
5285      // long-combined
5286 <    static abstract class OLMPap<T> extends ParallelArrayWithLongMapping<T> {
5286 >    abstract static class OLMPap<T> extends ParallelArrayWithLongMapping<T> {
5287          final ObjectToLong<? super T> op;
5288          OLMPap(ForkJoinPool ex, int origin, int fence,
5289                 T[] array, final ObjectToLong<? super T> op) {
# Line 5310 | Line 5312 | public abstract class AbstractParallelAn
5312          }
5313      }
5314  
5315 <    static abstract class DLMPap extends ParallelDoubleArrayWithLongMapping {
5315 >    abstract static class DLMPap extends ParallelDoubleArrayWithLongMapping {
5316          final DoubleToLong op;
5317          DLMPap(ForkJoinPool ex, int origin, int fence,
5318                 double[] array, DoubleToLong op) {
# Line 5340 | Line 5342 | public abstract class AbstractParallelAn
5342  
5343      }
5344  
5345 <    static abstract class LLMPap extends ParallelLongArrayWithLongMapping {
5345 >    abstract static class LLMPap extends ParallelLongArrayWithLongMapping {
5346          final LongOp op;
5347          LLMPap(ForkJoinPool ex, int origin, int fence,
5348                 long[] array, LongOp op) {
# Line 5387 | Line 5389 | public abstract class AbstractParallelAn
5389                                    CommonOps.compoundOp(this.op, op));
5390          }
5391  
5392 <        public <U> ParallelArrayWithMapping<T, U> withMapping
5392 >        public <U> ParallelArrayWithMapping<T,U> withMapping
5393              (LongToObject<? extends U> op) {
5394              return new OUOMPap<T,U>(ex, origin, fence, array,
5395                                      CommonOps.compoundOp(this.op, op));
# Line 5576 | Line 5578 | public abstract class AbstractParallelAn
5578                                    CommonOps.compoundOp(this.op, op));
5579          }
5580  
5581 <        public <U> ParallelArrayWithMapping<T, U> withMapping
5581 >        public <U> ParallelArrayWithMapping<T,U> withMapping
5582              (LongToObject<? extends U> op) {
5583              return new OFOMPap<T,U>(ex, origin, fence, array, selector,
5584                                      CommonOps.compoundOp(this.op, op));
# Line 5816 | Line 5818 | public abstract class AbstractParallelAn
5818                                    CommonOps.compoundOp(this.op, op));
5819          }
5820  
5821 <        public <U> ParallelArrayWithMapping<T, U> withMapping
5821 >        public <U> ParallelArrayWithMapping<T,U> withMapping
5822              (LongToObject<? extends U> op) {
5823              return new OROMPap<T,U>(ex, origin, fence, array, selector,
5824                                      CommonOps.compoundOp(this.op, op));
# Line 6032 | Line 6034 | public abstract class AbstractParallelAn
6034      }
6035  
6036      // long-combined
6037 <    static abstract class OLCPap<T> extends ParallelArrayWithLongMapping<T> {
6037 >    abstract static class OLCPap<T> extends ParallelArrayWithLongMapping<T> {
6038          final IntAndObjectToLong<? super T> op;
6039          OLCPap(ForkJoinPool ex, int origin, int fence,
6040                 T[] array, IntAndObjectToLong<? super T> op) {
# Line 6063 | Line 6065 | public abstract class AbstractParallelAn
6065          }
6066      }
6067  
6068 <    static abstract class DLCPap extends ParallelDoubleArrayWithLongMapping {
6068 >    abstract static class DLCPap extends ParallelDoubleArrayWithLongMapping {
6069          final IntAndDoubleToLong op;
6070          DLCPap(ForkJoinPool ex, int origin, int fence,
6071                 double[] array, IntAndDoubleToLong op) {
# Line 6094 | Line 6096 | public abstract class AbstractParallelAn
6096          }
6097      }
6098  
6099 <    static abstract class LLCPap extends ParallelLongArrayWithLongMapping {
6099 >    abstract static class LLCPap extends ParallelLongArrayWithLongMapping {
6100          final IntAndLongToLong op;
6101          LLCPap(ForkJoinPool ex, int origin, int fence,
6102                 long[] array, IntAndLongToLong op) {
# Line 6142 | Line 6144 | public abstract class AbstractParallelAn
6144                                    compoundIndexedOp(this.op, op));
6145          }
6146  
6147 <        public <U> ParallelArrayWithMapping<T, U> withMapping
6147 >        public <U> ParallelArrayWithMapping<T,U> withMapping
6148              (LongToObject<? extends U> op) {
6149              return new OUOCPap<T,U>(ex, origin, fence, array,
6150                                      compoundIndexedOp(this.op, op));
# Line 6327 | Line 6329 | public abstract class AbstractParallelAn
6329                                    compoundIndexedOp(this.op, op));
6330          }
6331  
6332 <        public <U> ParallelArrayWithMapping<T, U> withMapping
6332 >        public <U> ParallelArrayWithMapping<T,U> withMapping
6333              (LongToObject<? extends U> op) {
6334              return new OFOCPap<T,U>(ex, origin, fence, array,
6335                                      selector,
# Line 6569 | Line 6571 | public abstract class AbstractParallelAn
6571                                    compoundIndexedOp(this.op, op));
6572          }
6573  
6574 <        public <U> ParallelArrayWithMapping<T, U> withMapping
6574 >        public <U> ParallelArrayWithMapping<T,U> withMapping
6575              (LongToObject<? extends U> op) {
6576              return new OROCPap<T,U>(ex, origin, fence, array,
6577                                      selector,
# Line 6819 | Line 6821 | public abstract class AbstractParallelAn
6821          int cursor;
6822          FilteredAsDoubleIterator() {
6823              cursor = origin;
6824 <            advance() ;
6824 >            advance();
6825          }
6826          private void advance() {
6827              while (cursor < fence) {
# Line 6872 | Line 6874 | public abstract class AbstractParallelAn
6874          int cursor;
6875          FilteredAsLongIterator() {
6876              cursor = origin;
6877 <            advance() ;
6877 >            advance();
6878          }
6879          private void advance() {
6880              while (cursor < fence) {
# Line 6925 | Line 6927 | public abstract class AbstractParallelAn
6927          int cursor;
6928          FilteredIterator() {
6929              cursor = origin;
6930 <            advance() ;
6930 >            advance();
6931          }
6932          private void advance() {
6933              while (cursor < fence) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines