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

Comparing jsr166/src/extra166y/CommonOps.java (file contents):
Revision 1.1 by dl, Tue Jan 6 14:30:57 2009 UTC vs.
Revision 1.7 by jsr166, Tue Feb 5 17:46:29 2013 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   package extra166y;
# Line 17 | Line 17 | public class CommonOps {
17      private CommonOps() {} // disable construction
18  
19      /**
20 <     * Returns a Comparator for Comparable objects
20 >     * Returns a Comparator for Comparable objects.
21       */
22      public static <T extends Comparable<? super T>> Comparator<T>
23                               naturalComparator(Class<T> type) {
# Line 35 | Line 35 | public class CommonOps {
35          return new Reducer<T>() {
36              public T op(T a, T b) {
37                  return (a != null &&
38 <                        (b == null || a.compareTo(b) >= 0))? a : b;
38 >                        (b == null || a.compareTo(b) >= 0)) ? a : b;
39              }
40          };
41      }
# Line 49 | Line 49 | public class CommonOps {
49          return new Reducer<T>() {
50              public T op(T a, T b) {
51                  return (a != null &&
52 <                        (b == null || a.compareTo(b) <= 0))? a : b;
52 >                        (b == null || a.compareTo(b) <= 0)) ? a : b;
53              }
54          };
55      }
# Line 64 | Line 64 | public class CommonOps {
64          return new Reducer<T>() {
65              public T op(T a, T b) {
66                  return (a != null &&
67 <                        (b == null || comparator.compare(a, b) >= 0))? a : b;
67 >                        (b == null || comparator.compare(a, b) >= 0)) ? a : b;
68              }
69          };
70      }
# Line 79 | Line 79 | public class CommonOps {
79          return new Reducer<T>() {
80              public T op(T a, T b) {
81                  return (a != null &&
82 <                        (b == null || comparator.compare(a, b) <= 0))? a : b;
82 >                        (b == null || comparator.compare(a, b) <= 0)) ? a : b;
83              }
84          };
85      }
# Line 100 | Line 100 | public class CommonOps {
100  
101      /**
102       * Returns a reducer returning maximum of two values, or
103 <     * <tt>null</tt> if both arguments are null, and that casts
103 >     * {@code null} if both arguments are null, and that casts
104       * its arguments as Comparable on each comparison, throwing
105       * ClassCastException on failure.
106       */
# Line 112 | Line 112 | public class CommonOps {
112          public Object op(Object a, Object b) {
113              return (a != null &&
114                      (b == null ||
115 <                     ((Comparable)a).compareTo((Comparable)b) >= 0))? a : b;
115 >                     ((Comparable)a).compareTo((Comparable)b) >= 0)) ? a : b;
116          }
117      }
118  
119      /**
120       * Returns a reducer returning minimum of two values, or
121 <     * <tt>null</tt> if both arguments are null, and that casts
121 >     * {@code null} if both arguments are null, and that casts
122       * its arguments as Comparable on each comparison, throwing
123       * ClassCastException on failure.
124       */
# Line 130 | Line 130 | public class CommonOps {
130          public Object op(Object a, Object b) {
131              return (a != null &&
132                      (b == null ||
133 <                     ((Comparable)a).compareTo((Comparable)b) <= 0))? a : b;
133 >                     ((Comparable)a).compareTo((Comparable)b) <= 0)) ? a : b;
134          }
135      }
136  
137  
138      /**
139 <     * Returns a comparator for doubles relying on natural ordering
139 >     * Returns a comparator for doubles relying on natural ordering.
140       */
141      public static DoubleComparator naturalDoubleComparator() {
142          return NaturalDoubleComparator.comparator;
# Line 152 | Line 152 | public class CommonOps {
152  
153      /**
154       * Returns a reducer returning the maximum of two double elements,
155 <     * using natural comparator
155 >     * using natural comparator.
156       */
157      public static DoubleReducer naturalDoubleMaxReducer() {
158          return NaturalDoubleMaxReducer.max;
# Line 167 | Line 167 | public class CommonOps {
167  
168      /**
169       * Returns a reducer returning the minimum of two double elements,
170 <     * using natural comparator
170 >     * using natural comparator.
171       */
172      public static DoubleReducer naturalDoubleMinReducer() {
173          return NaturalDoubleMinReducer.min;
# Line 181 | Line 181 | public class CommonOps {
181  
182      /**
183       * Returns a reducer returning the maximum of two double elements,
184 <     * using the given comparator
184 >     * using the given comparator.
185       */
186      public static DoubleReducer doubleMaxReducer
187          (final DoubleComparator comparator) {
188          return new DoubleReducer() {
189                  public double op(double a, double b) {
190 <                    return (comparator.compare(a, b) >= 0)? a : b;
190 >                    return (comparator.compare(a, b) >= 0) ? a : b;
191                  }
192              };
193      }
194  
195      /**
196       * Returns a reducer returning the minimum of two double elements,
197 <     * using the given comparator
197 >     * using the given comparator.
198       */
199      public static DoubleReducer doubleMinReducer
200          (final DoubleComparator comparator) {
201          return new DoubleReducer() {
202                  public double op(double a, double b) {
203 <                    return (comparator.compare(a, b) <= 0)? a : b;
203 >                    return (comparator.compare(a, b) <= 0) ? a : b;
204                  }
205              };
206      }
207  
208      /**
209 <     * Returns a comparator for longs relying on natural ordering
209 >     * Returns a comparator for longs relying on natural ordering.
210       */
211      public static LongComparator naturalLongComparator() {
212          return NaturalLongComparator.comparator;
# Line 216 | Line 216 | public class CommonOps {
216          static final NaturalLongComparator comparator = new
217              NaturalLongComparator();
218          public int compare(long a, long b) {
219 <            return a < b? -1 : ((a > b)? 1 : 0);
219 >            return (a < b) ? -1 : ((a > b) ? 1 : 0);
220          }
221      }
222  
223      /**
224       * Returns a reducer returning the maximum of two long elements,
225 <     * using natural comparator
225 >     * using natural comparator.
226       */
227      public static LongReducer naturalLongMaxReducer() {
228          return NaturalLongMaxReducer.max;
# Line 232 | Line 232 | public class CommonOps {
232          implements LongReducer {
233          public static final NaturalLongMaxReducer max =
234              new NaturalLongMaxReducer();
235 <        public long op(long a, long b) { return a >= b? a : b; }
235 >        public long op(long a, long b) { return (a >= b) ? a : b; }
236      }
237  
238      /**
239       * A reducer returning the minimum of two long elements,
240 <     * using natural comparator
240 >     * using natural comparator.
241       */
242      public static LongReducer naturalLongMinReducer() {
243          return NaturalLongMinReducer.min;
# Line 246 | Line 246 | public class CommonOps {
246          implements LongReducer {
247          public static final NaturalLongMinReducer min =
248              new NaturalLongMinReducer();
249 <        public long op(long a, long b) { return a <= b? a : b; }
249 >        public long op(long a, long b) { return (a <= b) ? a : b; }
250      }
251  
252      /**
253       * Returns a reducer returning the maximum of two long elements,
254 <     * using the given comparator
254 >     * using the given comparator.
255       */
256      public static LongReducer longMaxReducer
257          (final LongComparator comparator) {
258          return new LongReducer() {
259                  public long op(long a, long b) {
260 <                    return (comparator.compare(a, b) >= 0)? a : b;
260 >                    return (comparator.compare(a, b) >= 0) ? a : b;
261                  }
262              };
263      }
264  
265      /**
266       * Returns a reducer returning the minimum of two long elements,
267 <     * using the given comparator
267 >     * using the given comparator.
268       */
269      public static LongReducer longMinReducer
270          (final LongComparator comparator) {
271          return new LongReducer() {
272                  public long op(long a, long b) {
273 <                    return (comparator.compare(a, b) <= 0)? a : b;
273 >                    return (comparator.compare(a, b) <= 0) ? a : b;
274                  }
275              };
276      }
277  
278      /**
279       * Returns a composite mapper that applies a second mapper to the results
280 <     * of applying the first one
280 >     * of applying the first one.
281       */
282      public static <T,U,V> Op<T,V> compoundOp
283          (final Op<? super T, ? extends U> first,
# Line 289 | Line 289 | public class CommonOps {
289  
290      /**
291       * Returns a composite mapper that applies a second mapper to the results
292 <     * of applying the first one
292 >     * of applying the first one.
293       */
294      public static <T,V> Op<T,V> compoundOp
295          (final ObjectToDouble<? super T> first,
# Line 301 | Line 301 | public class CommonOps {
301  
302      /**
303       * Returns a composite mapper that applies a second mapper to the results
304 <     * of applying the first one
304 >     * of applying the first one.
305       */
306      public static <T,V> Op<T,V> compoundOp
307          (final ObjectToLong<? super T> first,
# Line 313 | Line 313 | public class CommonOps {
313  
314      /**
315       * Returns a composite mapper that applies a second mapper to the results
316 <     * of applying the first one
316 >     * of applying the first one.
317       */
318      public static <T,V> DoubleToObject<V> compoundOp
319          (final DoubleToObject<? extends T> first,
# Line 325 | Line 325 | public class CommonOps {
325  
326      /**
327       * Returns a composite mapper that applies a second mapper to the results
328 <     * of applying the first one
328 >     * of applying the first one.
329       */
330      public static <T,V> LongToObject<V> compoundOp
331          (final LongToObject<? extends T> first,
# Line 337 | Line 337 | public class CommonOps {
337  
338      /**
339       * Returns a composite mapper that applies a second mapper to the results
340 <     * of applying the first one
340 >     * of applying the first one.
341       */
342      public static <T,U> ObjectToDouble<T> compoundOp
343          (final Op<? super T, ? extends U> first,
# Line 349 | Line 349 | public class CommonOps {
349  
350      /**
351       * Returns a composite mapper that applies a second mapper to the results
352 <     * of applying the first one
352 >     * of applying the first one.
353       */
354      public static <T,U> ObjectToLong<T> compoundOp
355          (final Op<? super T, ? extends U> first,
# Line 361 | Line 361 | public class CommonOps {
361  
362      /**
363       * Returns a composite mapper that applies a second mapper to the results
364 <     * of applying the first one
364 >     * of applying the first one.
365       */
366      public static <T> ObjectToDouble<T> compoundOp
367          (final ObjectToDouble<? super T> first,
# Line 373 | Line 373 | public class CommonOps {
373  
374      /**
375       * Returns a composite mapper that applies a second mapper to the results
376 <     * of applying the first one
376 >     * of applying the first one.
377       */
378      public static <T> ObjectToLong<T> compoundOp
379          (final ObjectToDouble<? super T> first,
# Line 385 | Line 385 | public class CommonOps {
385  
386      /**
387       * Returns a composite mapper that applies a second mapper to the results
388 <     * of applying the first one
388 >     * of applying the first one.
389       */
390      public static <T> ObjectToLong<T> compoundOp
391          (final ObjectToLong<? super T> first,
# Line 397 | Line 397 | public class CommonOps {
397  
398      /**
399       * Returns a composite mapper that applies a second mapper to the results
400 <     * of applying the first one
400 >     * of applying the first one.
401       */
402      public static <T> ObjectToDouble<T> compoundOp
403          (final ObjectToLong<? super T> first,
# Line 409 | Line 409 | public class CommonOps {
409  
410      /**
411       * Returns a composite mapper that applies a second mapper to the results
412 <     * of applying the first one
412 >     * of applying the first one.
413       */
414      public static DoubleOp compoundOp
415          (final DoubleOp first,
# Line 421 | Line 421 | public class CommonOps {
421  
422      /**
423       * Returns a composite mapper that applies a second mapper to the results
424 <     * of applying the first one
424 >     * of applying the first one.
425       */
426      public static DoubleToLong compoundOp
427          (final DoubleOp first,
# Line 433 | Line 433 | public class CommonOps {
433  
434      /**
435       * Returns a composite mapper that applies a second mapper to the results
436 <     * of applying the first one
436 >     * of applying the first one.
437       */
438      public static DoubleToLong compoundOp
439          (final DoubleToLong first,
# Line 445 | Line 445 | public class CommonOps {
445  
446      /**
447       * Returns a composite mapper that applies a second mapper to the results
448 <     * of applying the first one
448 >     * of applying the first one.
449       */
450      public static <T> DoubleToObject<T> compoundOp
451          (final DoubleToLong first,
# Line 457 | Line 457 | public class CommonOps {
457  
458      /**
459       * Returns a composite mapper that applies a second mapper to the results
460 <     * of applying the first one
460 >     * of applying the first one.
461       */
462      public static <T> LongToObject<T> compoundOp
463          (final LongToDouble first,
# Line 469 | Line 469 | public class CommonOps {
469  
470      /**
471       * Returns a composite mapper that applies a second mapper to the results
472 <     * of applying the first one
472 >     * of applying the first one.
473       */
474      public static LongToDouble compoundOp
475          (final LongOp first,
# Line 481 | Line 481 | public class CommonOps {
481  
482      /**
483       * Returns a composite mapper that applies a second mapper to the results
484 <     * of applying the first one
484 >     * of applying the first one.
485       */
486      public static LongToDouble compoundOp
487          (final LongToDouble first,
# Line 493 | Line 493 | public class CommonOps {
493  
494      /**
495       * Returns a composite mapper that applies a second mapper to the results
496 <     * of applying the first one
496 >     * of applying the first one.
497       */
498      public static <T> DoubleToObject<T> compoundOp
499          (final DoubleOp first,
# Line 505 | Line 505 | public class CommonOps {
505  
506      /**
507       * Returns a composite mapper that applies a second mapper to the results
508 <     * of applying the first one
508 >     * of applying the first one.
509       */
510      public static <T> LongToObject<T> compoundOp
511          (final LongOp first,
# Line 517 | Line 517 | public class CommonOps {
517  
518      /**
519       * Returns a composite mapper that applies a second mapper to the results
520 <     * of applying the first one
520 >     * of applying the first one.
521       */
522      public static <T> DoubleOp compoundOp
523          (final DoubleToObject<? extends T> first,
524 <         final ObjectToDouble<? super T>  second) {
524 >         final ObjectToDouble<? super T> second) {
525          return new DoubleOp() {
526                  public final double op(double t) { return second.op(first.op(t)); }
527              };
# Line 529 | Line 529 | public class CommonOps {
529  
530      /**
531       * Returns a composite mapper that applies a second mapper to the results
532 <     * of applying the first one
532 >     * of applying the first one.
533       */
534      public static <T> LongToDouble compoundOp
535          (final LongToObject<? extends T> first,
536 <         final ObjectToDouble<? super T>  second) {
536 >         final ObjectToDouble<? super T> second) {
537          return new LongToDouble() {
538                  public final double op(long t) { return second.op(first.op(t)); }
539              };
# Line 541 | Line 541 | public class CommonOps {
541  
542      /**
543       * Returns a composite mapper that applies a second mapper to the results
544 <     * of applying the first one
544 >     * of applying the first one.
545       */
546      public static <T> DoubleToLong compoundOp
547          (final DoubleToObject<? extends T> first,
548 <         final ObjectToLong<? super T>  second) {
548 >         final ObjectToLong<? super T> second) {
549          return new DoubleToLong() {
550                  public final long op(double t) { return second.op(first.op(t)); }
551              };
# Line 553 | Line 553 | public class CommonOps {
553  
554      /**
555       * Returns a composite mapper that applies a second mapper to the results
556 <     * of applying the first one
556 >     * of applying the first one.
557       */
558      public static <T> LongOp compoundOp
559          (final LongToObject<? extends T> first,
560 <         final ObjectToLong<? super T>  second) {
560 >         final ObjectToLong<? super T> second) {
561          return new LongOp() {
562                  public final long op(long t) { return second.op(first.op(t)); }
563              };
# Line 565 | Line 565 | public class CommonOps {
565  
566      /**
567       * Returns a composite mapper that applies a second mapper to the results
568 <     * of applying the first one
568 >     * of applying the first one.
569       */
570      public static LongOp compoundOp
571          (final LongOp first,
# Line 577 | Line 577 | public class CommonOps {
577  
578      /**
579       * Returns a composite mapper that applies a second mapper to the results
580 <     * of applying the first one
580 >     * of applying the first one.
581       */
582      public static DoubleOp compoundOp
583          (final DoubleToLong first,
# Line 589 | Line 589 | public class CommonOps {
589  
590      /**
591       * Returns a composite mapper that applies a second mapper to the results
592 <     * of applying the first one
592 >     * of applying the first one.
593       */
594      public static LongOp compoundOp
595          (final LongToDouble first,
# Line 600 | Line 600 | public class CommonOps {
600      }
601  
602      /**
603 <     * Returns a predicate evaluating to the negation of its contained predicate
603 >     * Returns a predicate evaluating to the negation of its contained predicate.
604       */
605      public static <T> Predicate<T> notPredicate
606          (final Predicate<T> pred) {
# Line 610 | Line 610 | public class CommonOps {
610      }
611  
612      /**
613 <     * Returns a predicate evaluating to the negation of its contained predicate
613 >     * Returns a predicate evaluating to the negation of its contained predicate.
614       */
615      public static DoublePredicate notPredicate
616          (final DoublePredicate pred) {
# Line 620 | Line 620 | public class CommonOps {
620      }
621  
622      /**
623 <     * Returns a predicate evaluating to the negation of its contained predicate
623 >     * Returns a predicate evaluating to the negation of its contained predicate.
624       */
625      public static LongPredicate notPredicate
626          (final LongPredicate pred) {
# Line 630 | Line 630 | public class CommonOps {
630      }
631  
632      /**
633 <     * Returns a predicate evaluating to the conjunction of its contained predicates
633 >     * Returns a predicate evaluating to the conjunction of its contained predicates.
634       */
635      public static <S, T extends S> Predicate<T> andPredicate
636                                  (final Predicate<S> first,
# Line 643 | Line 643 | public class CommonOps {
643      }
644  
645      /**
646 <     * Returns a predicate evaluating to the disjunction of its contained predicates
646 >     * Returns a predicate evaluating to the disjunction of its contained predicates.
647       */
648      public static <S, T extends S> Predicate<T> orPredicate
649                                  (final Predicate<S> first,
# Line 656 | Line 656 | public class CommonOps {
656      }
657  
658      /**
659 <     * Returns a predicate evaluating to the conjunction of its contained predicates
659 >     * Returns a predicate evaluating to the conjunction of its contained predicates.
660       */
661      public static DoublePredicate andPredicate
662          (final DoublePredicate first,
# Line 669 | Line 669 | public class CommonOps {
669      }
670  
671      /**
672 <     * Returns a predicate evaluating to the disjunction of its contained predicates
672 >     * Returns a predicate evaluating to the disjunction of its contained predicates.
673       */
674      public static DoublePredicate orPredicate
675          (final DoublePredicate first,
# Line 683 | Line 683 | public class CommonOps {
683  
684  
685      /**
686 <     * Returns a predicate evaluating to the conjunction of its contained predicates
686 >     * Returns a predicate evaluating to the conjunction of its contained predicates.
687       */
688      public static LongPredicate andPredicate
689          (final LongPredicate first,
# Line 696 | Line 696 | public class CommonOps {
696      }
697  
698      /**
699 <     * Returns a predicate evaluating to the disjunction of its contained predicates
699 >     * Returns a predicate evaluating to the disjunction of its contained predicates.
700       */
701      public static LongPredicate orPredicate
702          (final LongPredicate first,
# Line 709 | Line 709 | public class CommonOps {
709      }
710  
711      /**
712 <     * Returns a predicate evaluating to true if its argument is non-null
712 >     * Returns a predicate evaluating to true if its argument is non-null.
713       */
714 <    public static  Predicate<Object> isNonNullPredicate() {
714 >    public static Predicate<Object> isNonNullPredicate() {
715          return IsNonNullPredicate.predicate;
716      }
717      static final class IsNonNullPredicate implements Predicate<Object> {
# Line 723 | Line 723 | public class CommonOps {
723      }
724  
725      /**
726 <     * Returns a predicate evaluating to true if its argument is null
726 >     * Returns a predicate evaluating to true if its argument is null.
727       */
728 <    public static  Predicate<Object> isNullPredicate() {
728 >    public static Predicate<Object> isNullPredicate() {
729          return IsNullPredicate.predicate;
730      }
731      static final class IsNullPredicate implements Predicate<Object> {
# Line 761 | Line 761 | public class CommonOps {
761      }
762  
763      /**
764 <     * Returns a reducer that adds two double elements
764 >     * Returns a reducer that adds two double elements.
765       */
766      public static DoubleReducer doubleAdder() { return DoubleAdder.adder; }
767      static final class DoubleAdder implements DoubleReducer {
# Line 770 | Line 770 | public class CommonOps {
770      }
771  
772      /**
773 <     * Returns a reducer that adds two long elements
773 >     * Returns a reducer that adds two long elements.
774       */
775      public static LongReducer longAdder() { return LongAdder.adder; }
776      static final class LongAdder implements LongReducer {
# Line 779 | Line 779 | public class CommonOps {
779      }
780  
781      /**
782 <     * Returns a reducer that adds two int elements
782 >     * Returns a reducer that adds two int elements.
783       */
784      public static IntReducer intAdder() { return IntAdder.adder; }
785      static final class IntAdder implements IntReducer {
# Line 790 | Line 790 | public class CommonOps {
790      /**
791       * Returns a generator producing uniform random values between
792       * zero and one, with the same properties as {@link
793 <     * java.util.Random#nextDouble} but operating independently across
794 <     * ForkJoinWorkerThreads and usable only within forkjoin
795 <     * computations.
793 >     * java.util.Random#nextDouble}.
794       */
795      public static DoubleGenerator doubleRandom() {
796          return DoubleRandomGenerator.generator;
# Line 801 | Line 799 | public class CommonOps {
799          static final DoubleRandomGenerator generator =
800              new DoubleRandomGenerator();
801          public double op() {
802 <            return ForkJoinWorkerThread.nextRandomDouble();
802 >            return ThreadLocalRandom.current().nextDouble();
803          }
804      }
805  
806      /**
807       * Returns a generator producing uniform random values between
808       * zero and the given bound, with the same properties as {@link
809 <     * java.util.Random#nextDouble} but operating independently across
812 <     * ForkJoinWorkerThreads and usable only within forkjoin
813 <     * computations.
809 >     * java.util.Random#nextDouble}.
810       * @param bound the upper bound (exclusive) of opd values
811       */
812      public static DoubleGenerator doubleRandom(double bound) {
# Line 820 | Line 816 | public class CommonOps {
816          final double bound;
817          DoubleBoundedRandomGenerator(double bound) { this.bound = bound; }
818          public double op() {
819 <            return ForkJoinWorkerThread.nextRandomDouble() * bound;
819 >            return ThreadLocalRandom.current().nextDouble() * bound;
820          }
821      }
822  
823      /**
824       * Returns a generator producing uniform random values between the
825 <     * given least value (inclusive) and bound (exclusive), operating
830 <     * independently across ForkJoinWorkerThreads and usable only
831 <     * within forkjoin computations.
825 >     * given least value (inclusive) and bound (exclusive).
826       * @param least the least value returned
827       * @param bound the upper bound (exclusive) of opd values
828       */
# Line 842 | Line 836 | public class CommonOps {
836              this.least = least; this.range = bound - least;
837          }
838          public double op() {
839 <            return ForkJoinWorkerThread.nextRandomDouble() * range + least;
839 >            return ThreadLocalRandom.current().nextDouble() * range + least;
840          }
841      }
842  
843      /**
844       * Returns a generator producing uniform random values with the
845 <     * same properties as {@link java.util.Random#nextLong} but
852 <     * operating independently across ForkJoinWorkerThreads and usable
853 <     * only within forkjoin computations.
845 >     * same properties as {@link java.util.Random#nextLong}.
846       */
847      public static LongGenerator longRandom() {
848          return LongRandomGenerator.generator;
# Line 859 | Line 851 | public class CommonOps {
851          static final LongRandomGenerator generator =
852              new LongRandomGenerator();
853          public long op() {
854 <            return ForkJoinWorkerThread.nextRandomLong();
854 >            return ThreadLocalRandom.current().nextLong();
855          }
856      }
857  
858      /**
859       * Returns a generator producing uniform random values with the
860 <     * same properties as {@link java.util.Random#nextInt(int)} but
869 <     * operating independently across ForkJoinWorkerThreads and usable
870 <     * only within forkjoin computations.
860 >     * same properties as {@link java.util.Random#nextInt(int)}.
861       * @param bound the upper bound (exclusive) of opd values
862       */
863      public static LongGenerator longRandom(long bound) {
# Line 879 | Line 869 | public class CommonOps {
869          final long bound;
870          LongBoundedRandomGenerator(long bound) { this.bound = bound; }
871          public long op() {
872 <            return ForkJoinWorkerThread.nextRandomLong(bound);
872 >            return ThreadLocalRandom.current().nextLong(bound);
873          }
874      }
875  
876      /**
877       * Returns a generator producing uniform random values between the
878 <     * given least value (inclusive) and bound (exclusive), operating
889 <     * independently across ForkJoinWorkerThreads and usable only
890 <     * within forkjoin computations.
878 >     * given least value (inclusive) and bound (exclusive).
879       * @param least the least value returned
880       * @param bound the upper bound (exclusive) of opd values
881       */
# Line 903 | Line 891 | public class CommonOps {
891              this.least = least; this.range = bound - least;
892          }
893          public long op() {
894 <            return ForkJoinWorkerThread.nextRandomLong(range) + least;
894 >            return ThreadLocalRandom.current().nextLong(range) + least;
895          }
896      }
897  
898      /**
899       * Returns a generator producing uniform random values with the
900 <     * same properties as {@link java.util.Random#nextInt} but
913 <     * operating independently across ForkJoinWorkerThreads and usable
914 <     * only within forkjoin computations.
900 >     * same properties as {@link java.util.Random#nextInt}.
901       */
902      public static IntGenerator intRandom() {
903          return IntRandomGenerator.generator;
# Line 920 | Line 906 | public class CommonOps {
906          static final IntRandomGenerator generator =
907              new IntRandomGenerator();
908          public int op() {
909 <            return ForkJoinWorkerThread.nextRandomInt();
909 >            return ThreadLocalRandom.current().nextInt();
910          }
911      }
912  
913      /**
914       * Returns a generator producing uniform random values with the
915 <     * same properties as {@link java.util.Random#nextInt(int)} but
930 <     * operating independently across ForkJoinWorkerThreads and usable
931 <     * only within forkjoin computations.
915 >     * same properties as {@link java.util.Random#nextInt(int)}.
916       * @param bound the upper bound (exclusive) of opd values
917       */
918      public static IntGenerator intRandom(int bound) {
# Line 940 | Line 924 | public class CommonOps {
924          final int bound;
925          IntBoundedRandomGenerator(int bound) { this.bound = bound; }
926          public int op() {
927 <            return ForkJoinWorkerThread.nextRandomInt(bound);
927 >            return ThreadLocalRandom.current().nextInt(bound);
928          }
929      }
930  
931      /**
932       * Returns a generator producing uniform random values between the
933 <     * given least value (inclusive) and bound (exclusive), operating
950 <     * independently across ForkJoinWorkerThreads and usable only
951 <     * within forkjoin computations.
933 >     * given least value (inclusive) and bound (exclusive).
934       * @param least the least value returned
935       * @param bound the upper bound (exclusive) of opd values
936       */
# Line 964 | Line 946 | public class CommonOps {
946              this.least = least; this.range = bound - least;
947          }
948          public int op() {
949 <            return ForkJoinWorkerThread.nextRandomInt(range) + least;
949 >            return ThreadLocalRandom.current().nextInt(range) + least;
950          }
951      }
952  
953      /**
954       * Returns a predicate evaluating to true if the
955 <     * first argument <tt>equals</tt> the second
955 >     * first argument {@code equals} the second.
956       */
957      public static BinaryPredicate<Object, Object> equalityPredicate() {
958          return EqualityPredicate.predicate;
# Line 985 | Line 967 | public class CommonOps {
967  
968      /**
969       * Returns a predicate evaluating to true if the
970 <     * first argument <tt>==</tt> the second
970 >     * first argument {@code ==} the second.
971       */
972      public static BinaryPredicate<Object, Object> identityPredicate() {
973          return IdentityPredicate.predicate;
# Line 1000 | Line 982 | public class CommonOps {
982  
983      /**
984       * Returns a predicate evaluating to true if the
985 <     * first argument <tt>==</tt> the second
985 >     * first argument {@code ==} the second.
986       */
987      public static BinaryIntPredicate intEqualityPredicate() {
988          return IntEqualityPredicate.predicate;
# Line 1015 | Line 997 | public class CommonOps {
997  
998      /**
999       * Returns a predicate evaluating to true if the
1000 <     * first argument <tt>==</tt> the second
1000 >     * first argument {@code ==} the second.
1001       */
1002      public static BinaryLongPredicate longEqualityPredicate() {
1003          return LongEqualityPredicate.predicate;
# Line 1030 | Line 1012 | public class CommonOps {
1012  
1013      /**
1014       * Returns a predicate evaluating to true if the
1015 <     * first argument <tt>==</tt> the second
1015 >     * first argument {@code ==} the second.
1016       */
1017      public static BinaryDoublePredicate doubleEqualityPredicate() {
1018          return DoubleEqualityPredicate.predicate;
# Line 1046 | Line 1028 | public class CommonOps {
1028  
1029      /**
1030       * Returns a predicate evaluating to true if the
1031 <     * first argument <tt>!equals</tt> the second
1031 >     * first argument {@code !equals} the second.
1032       */
1033      public static BinaryPredicate<Object, Object> inequalityPredicate() {
1034          return InequalityPredicate.predicate;
# Line 1061 | Line 1043 | public class CommonOps {
1043  
1044      /**
1045       * Returns a predicate evaluating to true if the
1046 <     * first argument <tt>!=</tt> the second
1046 >     * first argument {@code !=} the second.
1047       */
1048      public static BinaryPredicate<Object, Object> nonidentityPredicate() {
1049          return NonidentityPredicate.predicate;
# Line 1076 | Line 1058 | public class CommonOps {
1058  
1059      /**
1060       * Returns a predicate evaluating to true if the
1061 <     * first argument <tt>!=</tt> the second
1061 >     * first argument {@code !=} the second.
1062       */
1063      public static BinaryIntPredicate intInequalityPredicate() {
1064          return IntInequalityPredicate.predicate;
# Line 1091 | Line 1073 | public class CommonOps {
1073  
1074      /**
1075       * Returns a predicate evaluating to true if the
1076 <     * first argument <tt>==</tt> the second
1076 >     * first argument {@code ==} the second.
1077       */
1078      public static BinaryLongPredicate longInequalityPredicate() {
1079          return LongInequalityPredicate.predicate;
# Line 1106 | Line 1088 | public class CommonOps {
1088  
1089      /**
1090       * Returns a predicate evaluating to true if the
1091 <     * first argument <tt>!=</tt> the second
1091 >     * first argument {@code !=} the second.
1092       */
1093      public static BinaryDoublePredicate doubleInequalityPredicate() {
1094          return DoubleInequalityPredicate.predicate;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines