Package org.apache.commons.rng.simple
Class JDKRandomBridge
- java.lang.Object
-
- java.util.Random
-
- org.apache.commons.rng.simple.JDKRandomBridge
-
- All Implemented Interfaces:
Serializable
public final class JDKRandomBridge extends Random
Subclass ofRandom
thatdelegates
to aRestorableUniformRandomProvider
instance but will otherwise rely on the base class for generating all the random types.Legacy applications coded against the JDK's API could use this subclass of
Random
in order to replace its linear congruential generator by anyRandomSource
.Caveat: Use of this class is not recommended for new applications. In particular, there is no guarantee that the serialized form of this class will be compatible across (even minor) releases of the library.
- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JDKRandomBridge(RandomSource source, Object seed)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
next(int n)
Delegates the generation of 32 random bits to theRandomSource
argument provided atconstruction
.void
setSeed(long seed)
-
-
-
Constructor Detail
-
JDKRandomBridge
public JDKRandomBridge(RandomSource source, Object seed)
Creates a new instance.- Parameters:
source
- Source of randomness.seed
- Seed. Can benull
.
-
-
Method Detail
-
next
protected int next(int n)
Delegates the generation of 32 random bits to theRandomSource
argument provided atconstruction
. The returned value is such that if the source of randomness isRandomSource.JDK
, all the generated values will be identical to those produced by the same sequence of calls on aRandom
instance initialized with the same seed.
-
-