org.apache.commons.rng.UniformRandomProvider
public final class JDKRandomWrapper extends java.lang.Object implements org.apache.commons.rng.UniformRandomProvider
Random
instance to implement UniformRandomProvider
. All methods from
the Random
that match those in UniformRandomProvider
are used directly.
This class can be used to wrap an instance of
SecureRandom
. The SecureRandom
class provides
cryptographic random number generation. The features available depend on the Java version
and platform. Consult the Java documentation for more details.
Note: Use of java.util.Random
is not recommended for applications.
There are many other pseudo-random number generators that are statistically superior and often
faster (see RandomSource
).
SecureRandom
,
RandomSource
Constructor | Description |
---|---|
JDKRandomWrapper(java.util.Random rng) |
Create a wrapper around a Random instance.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
nextBoolean() |
|
void |
nextBytes(byte[] bytes) |
|
void |
nextBytes(byte[] bytes,
int start,
int len) |
|
double |
nextDouble() |
|
float |
nextFloat() |
|
int |
nextInt() |
|
int |
nextInt(int n) |
|
long |
nextLong() |
|
long |
nextLong(long n) |
public JDKRandomWrapper(java.util.Random rng)
rng
- JDK Random
instance to which the random number
generation is delegated.public void nextBytes(byte[] bytes)
nextBytes
in interface org.apache.commons.rng.UniformRandomProvider
public void nextBytes(byte[] bytes, int start, int len)
nextBytes
in interface org.apache.commons.rng.UniformRandomProvider
public int nextInt()
nextInt
in interface org.apache.commons.rng.UniformRandomProvider
public int nextInt(int n)
nextInt
in interface org.apache.commons.rng.UniformRandomProvider
public long nextLong()
nextLong
in interface org.apache.commons.rng.UniformRandomProvider
public long nextLong(long n)
nextLong
in interface org.apache.commons.rng.UniformRandomProvider
public boolean nextBoolean()
nextBoolean
in interface org.apache.commons.rng.UniformRandomProvider
public float nextFloat()
nextFloat
in interface org.apache.commons.rng.UniformRandomProvider
public double nextDouble()
nextDouble
in interface org.apache.commons.rng.UniformRandomProvider
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.