Package mars.mips.instructions.syscalls
Class RandomStreams
java.lang.Object
mars.mips.instructions.syscalls.RandomStreams
This small class serves only to hold a static HashMap for storing
random number generators for use by all the random number generator
services.
-
Field Summary
FieldsModifier and TypeFieldDescriptionCollection of pseudorandom number streams available for use in the random syscalls. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Random
getStream
(int index) Get the pseudorandom number stream corresponding to the given index.static void
setStreamSeed
(int index, long seed) Set the seed of the pseudorandom number stream corresponding to the given index.
-
Field Details
-
RANDOM_STREAMS
Collection of pseudorandom number streams available for use in the random syscalls. The streams are by default not seeded.
-
-
Constructor Details
-
RandomStreams
public RandomStreams()
-
-
Method Details
-
getStream
Get the pseudorandom number stream corresponding to the given index. A new stream is created and returned if no stream currently exists for the index.- Parameters:
index
- The index used to access theRANDOM_STREAMS
map.- Returns:
- Random stream for the index.
-
setStreamSeed
public static void setStreamSeed(int index, long seed) Set the seed of the pseudorandom number stream corresponding to the given index. A new stream is created with the seed if no stream currently exists for the index.- Parameters:
index
- The index used to access theRANDOM_STREAMS
map.seed
- The value to seed the random stream with.
-