@Test public void intRange() { final Random rnd = new LCG64ShiftRandom(); final int min = 10; final int max = 10_000; for (int i = 0; i < 100_000; ++i) { final int n = Randoms.nextInt(min, max, rnd); Assert.assertTrue(n >= min, format("n < min: %d < %d", n, min)); Assert.assertTrue(n < max, format("n max: %d >= %d", n, max)); } }
public static int nextInt( final int origin, final int bound, final Random random ) { if (origin >= bound) { throw new IllegalArgumentException(format( "origin >= bound: %d >= %d", origin, bound )); } final int value; int n = bound - origin; if (n > 0) { value = random.nextInt(n) + origin; } else { int r; do { r = random.nextInt(); } while (r < origin || r >= bound); value = r; } return value; }
Randoms { public static int nextInt( final int origin, final int bound, final Random random ) { if (origin >= bound) { throw new IllegalArgumentException(format( "origin >= bound: %d >= %d", origin, bound )); } final int value; int n = bound - origin; if (n > 0) { value = random.nextInt(n) + origin; } else { int r; do { r = random.nextInt(); } while (r < origin || r >= bound); value = r; } return value; } }
Randoms { public static int nextInt( final int origin, final int bound, final Random random ) { if (origin >= bound) { throw new IllegalArgumentException(format( "origin >= bound: %d >= %d", origin, bound )); } final int value; int n = bound - origin; if (n > 0) { value = random.nextInt(n) + origin; } else { int r; do { r = random.nextInt(); } while (r < origin || r >= bound); value = r; } return value; } private  Randoms(); }
Randoms { public static int nextInt( final int origin, final int bound, final Random random ) { if (origin >= bound) { throw new IllegalArgumentException(format( "origin >= bound: %d >= %d", origin, bound )); } final int value; int n = bound - origin; if (n > 0) { value = random.nextInt(n) + origin; } else { int r; do { r = random.nextInt(); } while (r < origin || r >= bound); value = r; } return value; } private  Randoms(); static byte nextByte(final Random random); static char nextChar(final Random random); static short nextShort(final Random random); static int nextInt(
		final int origin,
		final int bound,
		final Random random
	); static int nextInt(final IntRange range, final Random random); static float nextFloat(
		final float min,
		final float max,
		final Random random
	); static double nextDouble(
		final double min,
		final double max,
		final Random random
	); static String nextASCIIString(final int length, final Random random); static String nextASCIIString(final Random random); static float toFloat(final int a); static float toFloat(final long a); static double toDouble(final long a); static double toDouble(final int a, final int b); static float toFloat2(final int a); static float toFloat2(final long a); static double toDouble2(final long a); static double toDouble2(final int a, final int b); static IntStream indexes(
		final Random random,
		final int start,
		final int end,
		final double p
	); static IntStream indexes(
		final Random random,
		final int n,
		final double p
	); static byte[] seedBytes(final int length); static byte[] seed(final byte[] seed); static long seed(); static long seed(final long base); }
Randoms { public static int nextInt( final int origin, final int bound, final Random random ) { if (origin >= bound) { throw new IllegalArgumentException(format( "origin >= bound: %d >= %d", origin, bound )); } final int value; int n = bound - origin; if (n > 0) { value = random.nextInt(n) + origin; } else { int r; do { r = random.nextInt(); } while (r < origin || r >= bound); value = r; } return value; } private  Randoms(); static byte nextByte(final Random random); static char nextChar(final Random random); static short nextShort(final Random random); static int nextInt(
		final int origin,
		final int bound,
		final Random random
	); static int nextInt(final IntRange range, final Random random); static float nextFloat(
		final float min,
		final float max,
		final Random random
	); static double nextDouble(
		final double min,
		final double max,
		final Random random
	); static String nextASCIIString(final int length, final Random random); static String nextASCIIString(final Random random); static float toFloat(final int a); static float toFloat(final long a); static double toDouble(final long a); static double toDouble(final int a, final int b); static float toFloat2(final int a); static float toFloat2(final long a); static double toDouble2(final long a); static double toDouble2(final int a, final int b); static IntStream indexes(
		final Random random,
		final int start,
		final int end,
		final double p
	); static IntStream indexes(
		final Random random,
		final int n,
		final double p
	); static byte[] seedBytes(final int length); static byte[] seed(final byte[] seed); static long seed(); static long seed(final long base);  }