Class Java2Random
java.lang.Object
java.util.Random
nl.tudelft.simulation.jstats.streams.Java2Random
- All Implemented Interfaces:
Serializable,RandomGenerator,StreamInterface
The Java2Random is an extension of the
java.util.Random class which implements the StreamInterface.
Copyright (c) 2002-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.
- Author:
- Alexander Verbraeck, Peter Jacobs
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new Java2Random and initializes with System.currentTimeMillis.Java2Random(long seed) Create a new Java2Random and initialize with a given seed. -
Method Summary
Modifier and TypeMethodDescriptionlongReturn the original seed of the generator with which it has been first initialized.longgetSeed()Return the seed of the generator.intnextInt(int i, int j) Return pseudo-random number from the stream between the integers i (inclusive) and j (inclusive).voidreset()Reset the stream to use the original seed with which it was initialized.voidsetSeed(long seed) Set the seed of the generator.Methods inherited from class java.util.Random
doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, next, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLongMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.random.RandomGenerator
isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextLong, nextLongMethods inherited from interface nl.tudelft.simulation.jstats.streams.StreamInterface
nextBoolean, nextDouble, nextFloat, nextInt, nextLong
-
Constructor Details
-
Java2Random
public Java2Random()Create a new Java2Random and initializes with System.currentTimeMillis. -
Java2Random
public Java2Random(long seed) Create a new Java2Random and initialize with a given seed.- Parameters:
seed- the seed to use.
-
-
Method Details
-
reset
public void reset()Description copied from interface:StreamInterfaceReset the stream to use the original seed with which it was initialized.- Specified by:
resetin interfaceStreamInterface
-
getOriginalSeed
public long getOriginalSeed()Description copied from interface:StreamInterfaceReturn the original seed of the generator with which it has been first initialized.- Specified by:
getOriginalSeedin interfaceStreamInterface- Returns:
- the original seed of the generator when it was first initialized
-
nextInt
public int nextInt(int i, int j) Description copied from interface:StreamInterfaceReturn pseudo-random number from the stream between the integers i (inclusive) and j (inclusive).- Specified by:
nextIntin interfaceRandomGenerator- Specified by:
nextIntin interfaceStreamInterface- Parameters:
i- the minimal valuej- the maximum value- Returns:
- a value between i and j
-
setSeed
public void setSeed(long seed) Description copied from interface:StreamInterfaceSet the seed of the generator.- Specified by:
setSeedin interfaceStreamInterface- Overrides:
setSeedin classRandom- Parameters:
seed- the new seed
-
getSeed
public long getSeed()Description copied from interface:StreamInterfaceReturn the seed of the generator.- Specified by:
getSeedin interfaceStreamInterface- Returns:
- the seed
-