src/java.base/share/classes/java/util/random/L64X1024Random.java
branchJDK-8193209-branch
changeset 57547 56cbdc3ea079
parent 57437 f02ffcb61dce
child 57684 7cb325557832
--- a/src/java.base/share/classes/java/util/random/L64X1024Random.java	Fri Jul 26 15:20:31 2019 -0300
+++ b/src/java.base/share/classes/java/util/random/L64X1024Random.java	Fri Jul 26 15:37:05 2019 -0300
@@ -27,12 +27,14 @@
 
 import java.math.BigInteger;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.random.RandomGenerator.SplittableGenerator;
+import java.util.random.RandomSupport.AbstractSplittableGenerator;
 
 /**
  * A generator of uniform pseudorandom values applicable for use in
  * (among other contexts) isolated parallel computations that may
  * generate subtasks.  Class {@link L64X1024Random} implements
- * interfaces {@link RandomNumberGenerator} and {@link SplittableRNG},
+ * interfaces {@link RandomGenerator} and {@link SplittableGenerator},
  * and therefore supports methods for producing pseudorandomly chosen
  * numbers of type {@code int}, {@code long}, {@code float}, and {@code double}
  * as well as creating new split-off {@link L64X1024Random} objects,
@@ -132,7 +134,7 @@
  *
  * @since 14
  */
-public final class L64X1024Random extends AbstractSplittableRNG {
+public final class L64X1024Random extends AbstractSplittableGenerator {
 
     /*
      * Implementation Overview.
@@ -172,7 +174,7 @@
     /**
      * The seed generator for default constructors.
      */
-    private static final AtomicLong defaultGen = new AtomicLong(RNGSupport.initialSeed());
+    private static final AtomicLong defaultGen = new AtomicLong(RandomSupport.initialSeed());
 
     /*
      * The period of this generator, which is (2**1024 - 1) * 2**64.
@@ -261,7 +263,7 @@
         // If x0, x1, ..., x15 are all zero (very unlikely), we must choose nonzero values.
         if ((x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15) == 0) {
             for (int j = 0; j < N; j++) {
-                this.x[j] = RNGSupport.mixStafford13(s += RNGSupport.GOLDEN_RATIO_64);
+                this.x[j] = RandomSupport.mixStafford13(s += RandomSupport.GOLDEN_RATIO_64);
             }
         }
     }
@@ -284,24 +286,24 @@
         // which will then be used to produce the first generated value.
         // The other x values are filled in as if by a SplitMix PRNG with
         // GOLDEN_RATIO_64 as the gamma value and Stafford13 as the mixer.
-        this(RNGSupport.mixMurmur64(seed ^= RNGSupport.SILVER_RATIO_64),
+        this(RandomSupport.mixMurmur64(seed ^= RandomSupport.SILVER_RATIO_64),
              1,
-             RNGSupport.mixStafford13(seed),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed += RNGSupport.GOLDEN_RATIO_64),
-             RNGSupport.mixStafford13(seed + RNGSupport.GOLDEN_RATIO_64));
+             RandomSupport.mixStafford13(seed),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed + RandomSupport.GOLDEN_RATIO_64));
     }
 
     /**
@@ -312,7 +314,7 @@
      */
     public L64X1024Random() {
         // Using GOLDEN_RATIO_64 here gives us a good Weyl sequence of values.
-        this(defaultGen.getAndAdd(RNGSupport.GOLDEN_RATIO_64));
+        this(defaultGen.getAndAdd(RandomSupport.GOLDEN_RATIO_64));
     }
 
     /**
@@ -324,7 +326,7 @@
      */
     public L64X1024Random(byte[] seed) {
         // Convert the seed to 18 long values, of which the last 16 are not all zero.
-        long[] data = RNGSupport.convertSeedBytesToLongs(seed, 18, 16);
+        long[] data = RandomSupport.convertSeedBytesToLongs(seed, 18, 16);
         long a = data[0], s = data[1];
         // Force a to be odd.
         this.a = a | 1;
@@ -348,12 +350,12 @@
      * and the same expected statistical properties apply to the
      * entire set of generators constructed by such recursive splitting.
      *
-     * @param source a {@link SplittableRNG} instance to be used instead
+     * @param source a {@link SplittableGenerator} instance to be used instead
      *               of this one as a source of pseudorandom bits used to
      *               initialize the state of the new ones.
      * @return a new instance of {@link L64X1024Random}
      */
-    public L64X1024Random split(SplittableRNG source) {
+    public L64X1024Random split(SplittableGenerator source) {
         // Literally pick a new instance "at random".
         return new L64X1024Random(source.nextLong(), source.nextLong(),
                                   source.nextLong(), source.nextLong(),