java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.std.Mt19937
- All Implemented Interfaces:
ConstJoltPhysicsObject,RandomNumberEngine,AutoCloseable,Comparable<JoltPhysicsObject>
Generate a pseudo-random sequence of integers using a 32-bit Mersenne
Twister. (native type: std::mt19937)
The algorithm isn't specific to Jolt Physics. It's included in Jolt JNI for expediency, since MutableCompoundShapeTest.h uses it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongmax()Return the maximum value that can be generated.longmin()Return the minimum value that can be generated.intnextInt()Return the next integer in the sequence.longReturn the next integer in the sequence.voidseed(int value) Seed the engine with the specified value.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, targetVaOrZero, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa, targetVaOrZero
-
Constructor Details
-
Mt19937
public Mt19937()Instantiate a generator. -
Mt19937
public Mt19937(int seed) Instantiate a generator using the specified 32-bit seed.- Parameters:
seed- for initialization
-
-
Method Details
-
max
public long max()Return the maximum value that can be generated.- Specified by:
maxin interfaceRandomNumberEngine- Returns:
- an unsigned 32-bit value
-
min
public long min()Return the minimum value that can be generated.- Specified by:
minin interfaceRandomNumberEngine- Returns:
- an unsigned 32-bit value
-
nextInt
public int nextInt()Return the next integer in the sequence.- Specified by:
nextIntin interfaceRandomNumberEngine- Returns:
- an signed 32-bit value
-
nextUnsigned
public long nextUnsigned()Return the next integer in the sequence.- Specified by:
nextUnsignedin interfaceRandomNumberEngine- Returns:
- an unsigned 32-bit value
-
seed
public void seed(int value) Seed the engine with the specified value.- Specified by:
seedin interfaceRandomNumberEngine- Parameters:
value- the value to use
-