src/java.base/share/classes/java/util/random/L128X256MixRandom.java
branchJDK-8193209-branch
changeset 57547 56cbdc3ea079
parent 57437 f02ffcb61dce
child 57684 7cb325557832
--- a/src/java.base/share/classes/java/util/random/L128X256MixRandom.java	Fri Jul 26 15:20:31 2019 -0300
+++ b/src/java.base/share/classes/java/util/random/L128X256MixRandom.java	Fri Jul 26 15:37:05 2019 -0300
@@ -27,12 +27,15 @@
 
 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 L128X256MixRandom} 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 L128X256MixRandom} objects,
@@ -143,7 +146,7 @@
  *
  * @since 14
  */
-public final class L128X256MixRandom extends AbstractSplittableRNG {
+public final class L128X256MixRandom extends AbstractSplittableGenerator {
 
     /*
      * Implementation Overview.
@@ -181,7 +184,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**256 - 1) * 2**128.
@@ -250,10 +253,10 @@
         // If x0, x1, x2, and x3 are all zero, we must choose nonzero values.
         if ((x0 | x1 | x2 | x3) == 0) {
             // At least three of the four values generated here will be nonzero.
-            this.x0 = RNGSupport.mixStafford13(sh += RNGSupport.GOLDEN_RATIO_64);
-            this.x1 = RNGSupport.mixStafford13(sh += RNGSupport.GOLDEN_RATIO_64);
-            this.x2 = RNGSupport.mixStafford13(sh += RNGSupport.GOLDEN_RATIO_64);
-            this.x3 = RNGSupport.mixStafford13(sh + RNGSupport.GOLDEN_RATIO_64);
+            this.x0 = RandomSupport.mixStafford13(sh += RandomSupport.GOLDEN_RATIO_64);
+            this.x1 = RandomSupport.mixStafford13(sh += RandomSupport.GOLDEN_RATIO_64);
+            this.x2 = RandomSupport.mixStafford13(sh += RandomSupport.GOLDEN_RATIO_64);
+            this.x3 = RandomSupport.mixStafford13(sh + RandomSupport.GOLDEN_RATIO_64);
         }
     }
 
@@ -275,14 +278,14 @@
         // 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),
-             RNGSupport.mixMurmur64(seed += RNGSupport.GOLDEN_RATIO_64),
+        this(RandomSupport.mixMurmur64(seed ^= RandomSupport.SILVER_RATIO_64),
+             RandomSupport.mixMurmur64(seed += RandomSupport.GOLDEN_RATIO_64),
              0,
              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));
+             RandomSupport.mixStafford13(seed),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed += RandomSupport.GOLDEN_RATIO_64),
+             RandomSupport.mixStafford13(seed + RandomSupport.GOLDEN_RATIO_64));
     }
 
     /**
@@ -293,7 +296,7 @@
      */
     public L128X256MixRandom() {
         // 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));
     }
 
     /**
@@ -305,7 +308,7 @@
      */
     public L128X256MixRandom(byte[] seed) {
         // Convert the seed to 6 long values, of which the last 4 are not all zero.
-        long[] data = RNGSupport.convertSeedBytesToLongs(seed, 6, 4);
+        long[] data = RandomSupport.convertSeedBytesToLongs(seed, 6, 4);
         long ah = data[0], al = data[1], sh = data[2], sl = data[3], x0 = data[4], x1 = data[5], x2 = data[6], x3 = data[7];
         // Force a to be odd.
         this.ah = ah;
@@ -331,12 +334,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 L128X256MixRandom}
      */
-    public L128X256MixRandom split(SplittableRNG source) {
+    public L128X256MixRandom split(SplittableGenerator source) {
         // Literally pick a new instance "at random".
         return new L128X256MixRandom(source.nextLong(), source.nextLong(),
                                      source.nextLong(), source.nextLong(),
@@ -359,7 +362,7 @@
         long q0 = x0, q1 = x1, q2 = x2, q3 = x3;
         { long t = q1 << 17; q2 ^= q0; q3 ^= q1; q1 ^= q2; q0 ^= q3; q2 ^= t; q3 = Long.rotateLeft(q3, 45); }  // xoshiro256 1.0
         x0 = q0; x1 = q1; x2 = q2; x3 = q3;
-        return RNGSupport.mixLea64(z);  // mixing function
+        return RandomSupport.mixLea64(z);  // mixing function
     }
 
     public BigInteger period() {