Class RandomStreams

java.lang.Object
mars.mips.instructions.syscalls.RandomStreams

public class RandomStreams extends Object
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 Details

    • RANDOM_STREAMS

      public static final HashMap<Integer,Random> 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

      public static Random getStream(int index)
      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 the RANDOM_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 the RANDOM_STREAMS map.
      seed - The value to seed the random stream with.