Skip to content
Permalink
Browse files
Consolidate Int/LongProvider to use next() as the source of random bits
This removes the mixed use of next and nextLong or nextInt. The next
method is default source of the random bits and should always be used.
  • Loading branch information
aherbert committed Mar 30, 2022
1 parent 34b22b3 commit ea379adf1c968405a2942ff4637183b66c53aaee
Showing 2 changed files with 7 additions and 7 deletions.
@@ -35,7 +35,7 @@
/**
* Provides a bit source for booleans.
*
* <p>A cached value from a call to {@link #nextInt()}.
* <p>A cached value from a call to {@link #next()}.
*
* <p>Only stores 31-bits when full as 1 bit has already been consumed.
* The sign bit is a flag that shifts down so the source eventually equals 1
@@ -117,19 +117,19 @@ public boolean nextBoolean() {
/** {@inheritDoc} */
@Override
public double nextDouble() {
return NumberFactory.makeDouble(nextInt(), nextInt());
return NumberFactory.makeDouble(next(), next());
}

/** {@inheritDoc} */
@Override
public float nextFloat() {
return NumberFactory.makeFloat(nextInt());
return NumberFactory.makeFloat(next());
}

/** {@inheritDoc} */
@Override
public long nextLong() {
return NumberFactory.makeLong(nextInt(), nextInt());
return NumberFactory.makeLong(next(), next());
}

/** {@inheritDoc} */
@@ -38,7 +38,7 @@
/**
* Provides a bit source for booleans.
*
* <p>A cached value from a call to {@link #nextLong()}.
* <p>A cached value from a call to {@link #next()}.
*
* <p>Only stores 63-bits when full as 1 bit has already been consumed.
* The sign bit is a flag that shifts down so the source eventually equals 1
@@ -49,7 +49,7 @@
/**
* Provides a source for ints.
*
* <p>A cached half-value value from a call to {@link #nextLong()}.
* <p>A cached half-value value from a call to {@link #next()}.
* The int is stored in the lower 32 bits with zeros in the upper bits.
* When empty this is set to negative to trigger a refill.
*/
@@ -135,7 +135,7 @@ public int nextInt() {
/** {@inheritDoc} */
@Override
public double nextDouble() {
return NumberFactory.makeDouble(nextLong());
return NumberFactory.makeDouble(next());
}

/** {@inheritDoc} */

0 comments on commit ea379ad

Please sign in to comment.