public final class JDKRandomBridge extends java.util.Random
Random
that delegates
to a
RestorableUniformRandomProvider
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 any RandomSource
.
Constructor | Description |
---|---|
JDKRandomBridge(RandomSource source,
java.lang.Object seed) |
Creates a new instance.
|
Modifier and Type | Method | Description |
---|---|---|
protected int |
next(int n) |
Delegates the generation of 32 random bits to the
RandomSource argument provided at
construction . |
void |
setSeed(long seed) |
public JDKRandomBridge(RandomSource source, java.lang.Object seed)
source
- Source of randomness.seed
- Seed. Can be null
.public void setSeed(long seed)
setSeed
in class java.util.Random
protected int next(int n)
RandomSource
argument provided at
construction
.
The returned value is such that if the source of randomness is
RandomSource.JDK
, all the generated values will be identical
to those produced by the same sequence of calls on a Random
instance initialized with the same seed.next
in class java.util.Random
n
- Number of random bits which the requested value must contain.n
high-order bits of a
pseudo-random 32-bits integer.Copyright © 2016–2018 The Apache Software Foundation. All rights reserved.