src/java.base/share/classes/java/util/random/SplittableRNG.java
branchJDK-8193209-branch
changeset 57437 f02ffcb61dce
parent 57436 b0c958c0e6c6
--- a/src/java.base/share/classes/java/util/random/SplittableRNG.java	Thu Jun 27 18:02:51 2019 -0300
+++ b/src/java.base/share/classes/java/util/random/SplittableRNG.java	Thu Jun 27 18:30:27 2019 -0300
@@ -22,7 +22,8 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package java.util;
+
+package java.util.random;
 
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
@@ -36,69 +37,68 @@
  * and furthermore can be <i>split</i> into two objects (the original
  * one and a new one) each of which obey that same protocol (and therefore
  * can be recursively split indefinitely).
- *
- * <p>Ideally, all {@code SplittableRNG} objects produced by recursive
- * splitting from a single original {@code SplittableRNG} object are
+ * <p>
+ * Ideally, all {@link SplittableRNG} objects produced by recursive
+ * splitting from a single original {@link SplittableRNG} object are
  * statistically independent of one another and individually uniform.
  * Therefore we would expect the set of values collectively generated
  * by a set of such objects to have the same statistical properties as
  * if the same quantity of values were generated by a single thread
- * using a single {@code SplittableRNG} object.  In practice, one must
+ * using a single {@link SplittableRNG} object.  In practice, one must
  * settle for some approximation to independence and uniformity.
- *
- * <p>Methods are provided to perform a single splitting operation and
+ * <p>
+ * Methods are provided to perform a single splitting operation and
  * also to produce a stream of generators split off from the original
  * (by either iterative or recursive splitting, or a combination).
- *
- * <p>An implementation of the {@code SplittableRng} interface must provide
+ * <p>
+ * An implementation of the {@link SplittableRNG} interface must provide
  * concrete definitions for the methods {@code nextInt()}, {@code nextLong},
- * {@code period()}, {@code split()}, {@code split(SplittableRng)},
- * {@code splits()}, {@code splits(long)}, {@code splits(SplittableRng)},
- * and {@code splits(long, SplittableRng)}.  Perhaps the most convenient
+ * {@code period()}, {@code split()}, {@code split(SplittableRNG)},
+ * {@code splits()}, {@code splits(long)}, {@code splits(SplittableRNG)},
+ * and {@code splits(long, SplittableRNG)}.  Perhaps the most convenient
  * way to implement this interface is to extend the abstract class
- * {@link java.util.AbstractSplittableRng}.
- *
- * <p>Objects that implement {@code java.util.SplittableRNG} are
+ * {@link AbstractSplittableRNG}.
+ * <p>
+ * Objects that implement {@link SplittableRNG} are
  * typically not cryptographically secure.  Consider instead using
  * {@link java.security.SecureRandom} to get a cryptographically
  * secure pseudo-random number generator for use by
  * security-sensitive applications.
  *
- * @author  Guy Steele
- * @since   1.9
+ * @since 14
  */
-public interface SplittableRng extends StreamableRng {
+public interface SplittableRNG extends StreamableRNG {
 
     /**
      * Returns a new pseudorandom number generator, split off from
-     * this one, that implements the {@code Rng} and {@code SplittableRng}
+     * this one, that implements the {@link RandomNumberGenerator} and {@link SplittableRNG}
      * interfaces.
      *
      * This pseudorandom number generator may be used as a source of
      * pseudorandom bits used to initialize the state the new one.
      *
-     * @return a new object that implements the {@code Rng} and
-     *         {@code SplittableRng} interfaces
+     * @return a new object that implements the {@link RandomNumberGenerator} and
+     *         {@link SplittableRNG} interfaces
      */
-    SplittableRng split();
+    SplittableRNG split();
 
     /**
      * Returns a new pseudorandom number generator, split off from
-     * this one, that implements the {@code Rng} and {@code SplittableRng}
+     * this one, that implements the {@link RandomNumberGenerator} and {@link SplittableRNG}
      * interfaces.
      *
-     * @param source a {@code SplittableRng} instance to be used instead
+     * @param source a {@link SplittableRNG} instance to be used instead
      *               of this one as a source of pseudorandom bits used to
      *               initialize the state of the new ones.
      *
-     * @return an object that implements the {@code Rng} and
-     *         {@code SplittableRng} interfaces
+     * @return an object that implements the {@link RandomNumberGenerator} and
+     *         {@link SplittableRNG} interfaces
      */
-    SplittableRng split(SplittableRng source);
+    SplittableRNG split(SplittableRNG source);
 
     /**
      * Returns an effectively unlimited stream of new pseudorandom
-     * number generators, each of which implements the {@code SplittableRng}
+     * number generators, each of which implements the {@link SplittableRNG}
      * interface.
      *
      * This pseudorandom number generator may be used as a source of
@@ -107,86 +107,92 @@
      * @implNote It is permitted to implement this method in a manner
      * equivalent to {@code splits(Long.MAX_VALUE)}.
      *
-     * @return a stream of {@code SplittableRng} objects
+     * @return a stream of {@link SplittableRNG} objects
      */
-    default Stream<SplittableRng> splits() {
-	return this.splits(this);
+    default Stream<SplittableRNG> splits() {
+        return this.splits(this);
     }
 
     /**
      * Returns a stream producing the given {@code streamSize} number of
      * new pseudorandom number generators, each of which implements the
-     * {@code SplittableRng} interface.
+     * {@link SplittableRNG} interface.
      *
      * This pseudorandom number generator may be used as a source of
      * pseudorandom bits used to initialize the state the new ones.
      *
      * @param streamSize the number of values to generate
-     * @return a stream of {@code SplittableRng} objects
+     *
+     * @return a stream of {@link SplittableRNG} objects
+     *
      * @throws IllegalArgumentException if {@code streamSize} is
      *         less than zero
      */
-    Stream<SplittableRng> splits(long streamSize);
+    Stream<SplittableRNG> splits(long streamSize);
 
     /**
      * Returns an effectively unlimited stream of new pseudorandom
-     * number generators, each of which implements the {@code SplittableRng}
+     * number generators, each of which implements the {@link SplittableRNG}
      * interface.
      *
-     * @implNote It is permitted to implement this method in a manner
-     * equivalent to {@code splits(Long.MAX_VALUE, source)}.
-     *
-     * @param source a {@code SplittableRng} instance to be used instead
+     * @param source a {@link SplittableRNG} 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 stream of {@code SplittableRng} objects
+     * @return a stream of {@link SplittableRNG} objects
+     *
+     * @implNote It is permitted to implement this method in a manner
+     *           equivalent to {@code splits(Long.MAX_VALUE, source)}.
      */
-    Stream<SplittableRng> splits(SplittableRng source);
+    Stream<SplittableRNG> splits(SplittableRNG source);
 
     /**
      * Returns a stream producing the given {@code streamSize} number of
      * new pseudorandom number generators, each of which implements the
-     * {@code SplittableRng} interface.
+     * {@link SplittableRNG} interface.
      *
      * @param streamSize the number of values to generate
-     * @param source a {@code SplittableRng} instance to be used instead
+     * @param source a {@link SplittableRNG} 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 stream of {@code SplittableRng} objects
+     *
+     * @return a stream of {@link SplittableRNG} objects
+     *
      * @throws IllegalArgumentException if {@code streamSize} is
      *         less than zero
      */
-    Stream<SplittableRng> splits(long streamSize, SplittableRng source);
+    Stream<SplittableRNG> splits(long streamSize, SplittableRNG source);
 
     /**
      * Returns an effectively unlimited stream of new pseudorandom
-     * number generators, each of which implements the {@code Rng}
+     * number generators, each of which implements the {@link RandomNumberGenerator}
      * interface.  Ideally the generators in the stream will appear
      * to be statistically independent.
      *
-     * @implNote The default implementation calls {@code splits()}.
+     * @return a stream of objects that implement the {@link RandomNumberGenerator} interface
      *
-     * @return a stream of objects that implement the {@code Rng} interface
+     * @implNote The default implementation calls {@code splits()}.
      */
-    default Stream<Rng> rngs() {
-	return this.splits().map(x -> (Rng)x);
+    default Stream<RandomNumberGenerator> rngs() {
+        return this.splits().map(x -> (RandomNumberGenerator)x);
     }
 
     /**
      * Returns a stream producing the given {@code streamSize} number of
      * new pseudorandom number generators, each of which implements the
-     * {@code Rng} interface.  Ideally the generators in the stream will
+     * {@link RandomNumberGenerator} interface.  Ideally the generators in the stream will
      * appear to be statistically independent.
      *
-     * @implNote The default implementation calls {@code splits(streamSize)}.
-     *
      * @param streamSize the number of generators to generate
-     * @return a stream of objects that implement the {@code Rng} interface
+     *
+     * @return a stream of objects that implement the {@link RandomNumberGenerator} interface
+     *
      * @throws IllegalArgumentException if {@code streamSize} is
      *         less than zero
+     *
+     * @implNote The default implementation calls {@code splits(streamSize)}.
      */
-    default Stream<Rng> rngs(long streamSize) {
-	return this.splits(streamSize).map(x -> (Rng)x);
+    default Stream<RandomNumberGenerator> rngs(long streamSize) {
+        return this.splits(streamSize).map(x -> (RandomNumberGenerator)x);
     }
 }