--- jsr166/src/extra166y/CommonOps.java 2009/01/06 14:30:57 1.1 +++ jsr166/src/extra166y/CommonOps.java 2010/10/22 05:18:30 1.3 @@ -35,7 +35,7 @@ public class CommonOps { return new Reducer() { public T op(T a, T b) { return (a != null && - (b == null || a.compareTo(b) >= 0))? a : b; + (b == null || a.compareTo(b) >= 0)) ? a : b; } }; } @@ -49,7 +49,7 @@ public class CommonOps { return new Reducer() { public T op(T a, T b) { return (a != null && - (b == null || a.compareTo(b) <= 0))? a : b; + (b == null || a.compareTo(b) <= 0)) ? a : b; } }; } @@ -64,7 +64,7 @@ public class CommonOps { return new Reducer() { public T op(T a, T b) { return (a != null && - (b == null || comparator.compare(a, b) >= 0))? a : b; + (b == null || comparator.compare(a, b) >= 0)) ? a : b; } }; } @@ -79,7 +79,7 @@ public class CommonOps { return new Reducer() { public T op(T a, T b) { return (a != null && - (b == null || comparator.compare(a, b) <= 0))? a : b; + (b == null || comparator.compare(a, b) <= 0)) ? a : b; } }; } @@ -112,7 +112,7 @@ public class CommonOps { public Object op(Object a, Object b) { return (a != null && (b == null || - ((Comparable)a).compareTo((Comparable)b) >= 0))? a : b; + ((Comparable)a).compareTo((Comparable)b) >= 0)) ? a : b; } } @@ -130,7 +130,7 @@ public class CommonOps { public Object op(Object a, Object b) { return (a != null && (b == null || - ((Comparable)a).compareTo((Comparable)b) <= 0))? a : b; + ((Comparable)a).compareTo((Comparable)b) <= 0)) ? a : b; } } @@ -187,7 +187,7 @@ public class CommonOps { (final DoubleComparator comparator) { return new DoubleReducer() { public double op(double a, double b) { - return (comparator.compare(a, b) >= 0)? a : b; + return (comparator.compare(a, b) >= 0) ? a : b; } }; } @@ -200,7 +200,7 @@ public class CommonOps { (final DoubleComparator comparator) { return new DoubleReducer() { public double op(double a, double b) { - return (comparator.compare(a, b) <= 0)? a : b; + return (comparator.compare(a, b) <= 0) ? a : b; } }; } @@ -216,7 +216,7 @@ public class CommonOps { static final NaturalLongComparator comparator = new NaturalLongComparator(); public int compare(long a, long b) { - return a < b? -1 : ((a > b)? 1 : 0); + return (a < b) ? -1 : ((a > b) ? 1 : 0); } } @@ -232,7 +232,7 @@ public class CommonOps { implements LongReducer { public static final NaturalLongMaxReducer max = new NaturalLongMaxReducer(); - public long op(long a, long b) { return a >= b? a : b; } + public long op(long a, long b) { return (a >= b) ? a : b; } } /** @@ -246,7 +246,7 @@ public class CommonOps { implements LongReducer { public static final NaturalLongMinReducer min = new NaturalLongMinReducer(); - public long op(long a, long b) { return a <= b? a : b; } + public long op(long a, long b) { return (a <= b) ? a : b; } } /** @@ -257,7 +257,7 @@ public class CommonOps { (final LongComparator comparator) { return new LongReducer() { public long op(long a, long b) { - return (comparator.compare(a, b) >= 0)? a : b; + return (comparator.compare(a, b) >= 0) ? a : b; } }; } @@ -270,7 +270,7 @@ public class CommonOps { (final LongComparator comparator) { return new LongReducer() { public long op(long a, long b) { - return (comparator.compare(a, b) <= 0)? a : b; + return (comparator.compare(a, b) <= 0) ? a : b; } }; } @@ -790,9 +790,7 @@ public class CommonOps { /** * Returns a generator producing uniform random values between * zero and one, with the same properties as {@link - * java.util.Random#nextDouble} but operating independently across - * ForkJoinWorkerThreads and usable only within forkjoin - * computations. + * java.util.Random#nextDouble} */ public static DoubleGenerator doubleRandom() { return DoubleRandomGenerator.generator; @@ -801,16 +799,14 @@ public class CommonOps { static final DoubleRandomGenerator generator = new DoubleRandomGenerator(); public double op() { - return ForkJoinWorkerThread.nextRandomDouble(); + return ThreadLocalRandom.current().nextDouble(); } } /** * Returns a generator producing uniform random values between * zero and the given bound, with the same properties as {@link - * java.util.Random#nextDouble} but operating independently across - * ForkJoinWorkerThreads and usable only within forkjoin - * computations. + * java.util.Random#nextDouble}. * @param bound the upper bound (exclusive) of opd values */ public static DoubleGenerator doubleRandom(double bound) { @@ -820,15 +816,13 @@ public class CommonOps { final double bound; DoubleBoundedRandomGenerator(double bound) { this.bound = bound; } public double op() { - return ForkJoinWorkerThread.nextRandomDouble() * bound; + return ThreadLocalRandom.current().nextDouble() * bound; } } /** * Returns a generator producing uniform random values between the - * given least value (inclusive) and bound (exclusive), operating - * independently across ForkJoinWorkerThreads and usable only - * within forkjoin computations. + * given least value (inclusive) and bound (exclusive) * @param least the least value returned * @param bound the upper bound (exclusive) of opd values */ @@ -842,15 +836,13 @@ public class CommonOps { this.least = least; this.range = bound - least; } public double op() { - return ForkJoinWorkerThread.nextRandomDouble() * range + least; + return ThreadLocalRandom.current().nextDouble() * range + least; } } /** * Returns a generator producing uniform random values with the - * same properties as {@link java.util.Random#nextLong} but - * operating independently across ForkJoinWorkerThreads and usable - * only within forkjoin computations. + * same properties as {@link java.util.Random#nextLong} */ public static LongGenerator longRandom() { return LongRandomGenerator.generator; @@ -859,15 +851,13 @@ public class CommonOps { static final LongRandomGenerator generator = new LongRandomGenerator(); public long op() { - return ForkJoinWorkerThread.nextRandomLong(); + return ThreadLocalRandom.current().nextLong(); } } /** * Returns a generator producing uniform random values with the - * same properties as {@link java.util.Random#nextInt(int)} but - * operating independently across ForkJoinWorkerThreads and usable - * only within forkjoin computations. + * same properties as {@link java.util.Random#nextInt(int)} * @param bound the upper bound (exclusive) of opd values */ public static LongGenerator longRandom(long bound) { @@ -879,15 +869,13 @@ public class CommonOps { final long bound; LongBoundedRandomGenerator(long bound) { this.bound = bound; } public long op() { - return ForkJoinWorkerThread.nextRandomLong(bound); + return ThreadLocalRandom.current().nextLong(bound); } } /** * Returns a generator producing uniform random values between the - * given least value (inclusive) and bound (exclusive), operating - * independently across ForkJoinWorkerThreads and usable only - * within forkjoin computations. + * given least value (inclusive) and bound (exclusive). * @param least the least value returned * @param bound the upper bound (exclusive) of opd values */ @@ -903,15 +891,13 @@ public class CommonOps { this.least = least; this.range = bound - least; } public long op() { - return ForkJoinWorkerThread.nextRandomLong(range) + least; + return ThreadLocalRandom.current().nextLong(range) + least; } } /** * Returns a generator producing uniform random values with the - * same properties as {@link java.util.Random#nextInt} but - * operating independently across ForkJoinWorkerThreads and usable - * only within forkjoin computations. + * same properties as {@link java.util.Random#nextInt} */ public static IntGenerator intRandom() { return IntRandomGenerator.generator; @@ -920,15 +906,13 @@ public class CommonOps { static final IntRandomGenerator generator = new IntRandomGenerator(); public int op() { - return ForkJoinWorkerThread.nextRandomInt(); + return ThreadLocalRandom.current().nextInt(); } } /** * Returns a generator producing uniform random values with the - * same properties as {@link java.util.Random#nextInt(int)} but - * operating independently across ForkJoinWorkerThreads and usable - * only within forkjoin computations. + * same properties as {@link java.util.Random#nextInt(int)} * @param bound the upper bound (exclusive) of opd values */ public static IntGenerator intRandom(int bound) { @@ -940,15 +924,13 @@ public class CommonOps { final int bound; IntBoundedRandomGenerator(int bound) { this.bound = bound; } public int op() { - return ForkJoinWorkerThread.nextRandomInt(bound); + return ThreadLocalRandom.current().nextInt(bound); } } /** * Returns a generator producing uniform random values between the - * given least value (inclusive) and bound (exclusive), operating - * independently across ForkJoinWorkerThreads and usable only - * within forkjoin computations. + * given least value (inclusive) and bound (exclusive) * @param least the least value returned * @param bound the upper bound (exclusive) of opd values */ @@ -964,7 +946,7 @@ public class CommonOps { this.least = least; this.range = bound - least; } public int op() { - return ForkJoinWorkerThread.nextRandomInt(range) + least; + return ThreadLocalRandom.current().nextInt(range) + least; } }