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

Comparing jsr166/src/main/java/util/SplittableRandom.java (file contents):
Revision 1.1 by dl, Wed Jul 10 15:40:19 2013 UTC vs.
Revision 1.4 by dl, Thu Jul 11 13:40:42 2013 UTC

# Line 40 | Line 40 | import java.util.stream.DoubleStream;
40   * A generator of uniform pseudorandom values applicable for use in
41   * (among other contexts) isolated parallel computations that may
42   * generate subtasks. Class SplittableRandom supports methods for
43 < * producing pseudorandom nunmbers of type {@code int}, {@code long},
43 > * producing pseudorandom numbers of type {@code int}, {@code long},
44   * and {@code double} with similar usages as for class
45   * {@link java.util.Random} but differs in the following ways: <ul>
46   *
# Line 74 | Line 74 | import java.util.stream.DoubleStream;
74   * </ul>
75   *
76   * @author  Guy Steele
77 + * @author  Doug Lea
78   * @since   1.8
79   */
80   public class SplittableRandom {
# Line 112 | Line 113 | public class SplittableRandom {
113       * The value of gamma differs for each instance across a series of
114       * splits, and is generated using a slightly stripped-down variant
115       * of the same algorithm, but operating across calls to split(),
116 <     * not calls to nextLong(): Each instance carries the state of
116 >     * not calls to nextSeed(): Each instance carries the state of
117       * this generator as nextSplit, and uses mix64(nextSplit) as its
118       * own gamma value. Computations of gammas themselves use a fixed
119       * constant as the second argument to the addGammaModGeorge
# Line 310 | Line 311 | public class SplittableRandom {
311           * evenly divisible by the range. The loop rejects candidates
312           * computed from otherwise over-represented values.  The
313           * expected number of iterations under an ideal generator
314 <         * varies from 1 to 2, depending on the bound.
314 >         * varies from 1 to 2, depending on the bound. The loop itself
315 >         * takes an unlovable form. Because the first candidate is
316 >         * already available, we need a break-in-the-middle
317 >         * construction, which is concisely but cryptically performed
318 >         * within the while-condition of a body-less for loop.
319           *
320           * 4. Otherwise, the range cannot be represented as a positive
321 <         * long.  Repeatedly generate unbounded longs until obtaining
322 <         * a candidate meeting constraints (with an expected number of
323 <         * iterations of less than two).
321 >         * long.  The loop repeatedly generates unbounded longs until
322 >         * obtaining a candidate meeting constraints (with an expected
323 >         * number of iterations of less than two).
324           */
325  
326          long r = mix64(nextSeed());
# Line 752 | Line 757 | public class SplittableRandom {
757  
758      /**
759       * Returns a stream with the given {@code streamSize} number of
760 <     * pseudorandom {@code double} values.
760 >     * pseudorandom {@code double} values, each between {@code 0.0}
761 >     * (inclusive) and {@code 1.0} (exclusive).
762       *
763       * @param streamSize the number of values to generate
764       * @return a stream of {@code double} values
# Line 770 | Line 776 | public class SplittableRandom {
776  
777      /**
778       * Returns an effectively unlimited stream of pseudorandom {@code
779 <     * double} values.
779 >     * double} values, each between {@code 0.0} (inclusive) and {@code
780 >     * 1.0} (exclusive).
781       *
782       * @implNote This method is implemented to be equivalent to {@code
783       * doubles(Long.MAX_VALUE)}.
# Line 866 | Line 873 | public class SplittableRandom {
873  
874          public int characteristics() {
875              return (Spliterator.SIZED | Spliterator.SUBSIZED |
876 <                    Spliterator.ORDERED | Spliterator.NONNULL |
870 <                    Spliterator.IMMUTABLE);
876 >                    Spliterator.NONNULL | Spliterator.IMMUTABLE);
877          }
878  
879          public boolean tryAdvance(IntConsumer consumer) {
# Line 921 | Line 927 | public class SplittableRandom {
927  
928          public int characteristics() {
929              return (Spliterator.SIZED | Spliterator.SUBSIZED |
930 <                    Spliterator.ORDERED | Spliterator.NONNULL |
925 <                    Spliterator.IMMUTABLE);
930 >                    Spliterator.NONNULL | Spliterator.IMMUTABLE);
931          }
932  
933          public boolean tryAdvance(LongConsumer consumer) {
# Line 977 | Line 982 | public class SplittableRandom {
982  
983          public int characteristics() {
984              return (Spliterator.SIZED | Spliterator.SUBSIZED |
985 <                    Spliterator.ORDERED | Spliterator.NONNULL |
981 <                    Spliterator.IMMUTABLE);
985 >                    Spliterator.NONNULL | Spliterator.IMMUTABLE);
986          }
987  
988          public boolean tryAdvance(DoubleConsumer consumer) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines