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 aRandominstance to implementUniformRandomProvider. All methods from theRandomthat match those inUniformRandomProviderare used directly.This class can be used to wrap an instance of
SecureRandom. TheSecureRandomclass 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.Randomis 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 booleannextBoolean()voidnextBytes(byte[] bytes)voidnextBytes(byte[] bytes, int start, int len)doublenextDouble()floatnextFloat()intnextInt()intnextInt(int n)longnextLong()longnextLong(long n)
-
-
-
Constructor Detail
-
JDKRandomWrapper
public JDKRandomWrapper(Random rng)
Create a wrapper around a Random instance.- Parameters:
rng- JDKRandominstance to which the random number generation is delegated.
-
-
Method Detail
-
nextBytes
public void nextBytes(byte[] bytes)
- Specified by:
nextBytesin interfaceUniformRandomProvider
-
nextBytes
public void nextBytes(byte[] bytes, int start, int len)
- Specified by:
nextBytesin interfaceUniformRandomProvider
-
nextInt
public int nextInt()
- Specified by:
nextIntin interfaceUniformRandomProvider
-
nextInt
public int nextInt(int n)
- Specified by:
nextIntin interfaceUniformRandomProvider
-
nextLong
public long nextLong()
- Specified by:
nextLongin interfaceUniformRandomProvider
-
nextLong
public long nextLong(long n)
- Specified by:
nextLongin interfaceUniformRandomProvider
-
nextBoolean
public boolean nextBoolean()
- Specified by:
nextBooleanin interfaceUniformRandomProvider
-
nextFloat
public float nextFloat()
- Specified by:
nextFloatin interfaceUniformRandomProvider
-
nextDouble
public double nextDouble()
- Specified by:
nextDoublein interfaceUniformRandomProvider
-
-