Package org.apache.commons.rng.simple
Class JDKRandomWrapper
- java.lang.Object
-
- org.apache.commons.rng.simple.JDKRandomWrapper
-
- All Implemented Interfaces:
UniformRandomProvider
public final class JDKRandomWrapper extends Object implements UniformRandomProvider
Wraps aRandom
instance to implementUniformRandomProvider
. All methods from theRandom
that match those inUniformRandomProvider
are used directly.This class can be used to wrap an instance of
SecureRandom
. TheSecureRandom
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 (seeRandomSource
).- Since:
- 1.3
- See Also:
SecureRandom
,RandomSource
-
-
Constructor Summary
Constructors Constructor Description JDKRandomWrapper(Random rng)
Create a wrapper around a Random instance.
-
Method Summary
All Methods Instance Methods Concrete Methods 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)
-
-
-
Constructor Detail
-
JDKRandomWrapper
public JDKRandomWrapper(Random rng)
Create a wrapper around a Random instance.- Parameters:
rng
- JDKRandom
instance to which the random number generation is delegated.
-
-
Method Detail
-
nextBytes
public void nextBytes(byte[] bytes)
- Specified by:
nextBytes
in interfaceUniformRandomProvider
-
nextBytes
public void nextBytes(byte[] bytes, int start, int len)
- Specified by:
nextBytes
in interfaceUniformRandomProvider
-
nextInt
public int nextInt()
- Specified by:
nextInt
in interfaceUniformRandomProvider
-
nextInt
public int nextInt(int n)
- Specified by:
nextInt
in interfaceUniformRandomProvider
-
nextLong
public long nextLong()
- Specified by:
nextLong
in interfaceUniformRandomProvider
-
nextLong
public long nextLong(long n)
- Specified by:
nextLong
in interfaceUniformRandomProvider
-
nextBoolean
public boolean nextBoolean()
- Specified by:
nextBoolean
in interfaceUniformRandomProvider
-
nextFloat
public float nextFloat()
- Specified by:
nextFloat
in interfaceUniformRandomProvider
-
nextDouble
public double nextDouble()
- Specified by:
nextDouble
in interfaceUniformRandomProvider
-
-