RNStreamProviderIfc

An interface to define the ability to provide random number streams (RNStreamIfc) Conceptualizes this process as making a sequence of streams, numbered 1, 2, 3, ... for use in generating pseudo-random numbers that can be controlled.

Inheritors

Properties

Link copied to clipboard
abstract val defaultStreamNumber: Int

The sequence number associated with the default random number stream. This allows clients to know what stream number has been assigned to the default.

Link copied to clipboard

When the number of streams provided reaches this limit a warning is issued. This warning may indicate that a conceptual misunderstanding is occurring that is causing a large number of streams to be used. Generally, a small number of streams should be used, with each stream being accessed many times.

Functions

Link copied to clipboard

Causes all streams that have been provided to advance to the start of their next sub-stream. Thus, the individual streams skip any pseudo-random numbers in their current sub-stream and are positioned at the beginning of their next sub-stream. Note: This call only effects previously provided streams.

Link copied to clipboard
abstract fun advanceStreamMechanism(n: Int)

Advances the state of the provider through n streams. Acts as if n streams were created, without actually creating the streams. lastRNStreamNumber() remains the same after calling this method. In other words, this method should act as if nextRNStream() was not called but advance the underlying stream mechanism as if n streams had been provided.

Link copied to clipboard

It is useful to designate one of the streams in the sequence of streams as the default stream from the provider. When clients don't care to get new streams, this method guarantees that the same stream is returned every time.

Link copied to clipboard
open fun hasProvided(stream: RNStreamIfc): Boolean
Link copied to clipboard
abstract fun lastRNStreamNumber(): Int

Each call to nextStream() makes another stream in the sequence of streams. This method should return the number of streams provided by the provider. If nextStream() is called once, then lastRNStreamNumber() should return 1. If nextStream() is called twice then lastRNStreamNumber() should return 2, etc. Thus, this method returns the number in the sequence associated with the last stream made. If lastRNStreamNumber() returns 0, then no streams have been provided.

Link copied to clipboard
abstract fun nextRNStream(): RNStreamIfc

Tells the provider to make and return the next RNStreamIfc in the sequence of streams

Link copied to clipboard

Causes all streams that have been provided to be reset to the start of their stream. Thus, the individual streams act as if they have not generated any pseudo-random numbers. Note: This call only effects previously provided streams.

Link copied to clipboard

Causes all streams that have been provided to be reset to the start of their current sub-stream. Thus, the individual streams act as if they have not generated any pseudo-random numbers relative to their current sub-stream. Note: This call only effects previously provided streams.

Link copied to clipboard
abstract fun resetRNStreamSequence()

Causes the provider to act as if it has never created any streams. Thus, the next call to nextRNStream() after the reset should return the 1st stream in the sequence of streams that this provider would normally provide in the order in which they would be provided.

Link copied to clipboard
abstract fun rnStream(i: Int): RNStreamIfc

Tells the provider to return the ith stream of the sequence of streams that it provides. If i is greater than lastRNStreamNumber() then lastRNStreamNumber() is advanced according to the additional number of streams. For example, if lastRNStreamNumber() = 10 and i = 15, then streams 11, 12, 13, 14, 15 are assumed provided and stream 15 is returned and lastRNStreamNumber() now equals 15. If i is less than or equal to lastRNStreamNumber(), then no new streams are created, lastRNStreamNumber() stays at its current value and the ith stream is returned.

Link copied to clipboard

Causes all streams that have been provided to change their antithetic option to the supplied value. Any new streams provided after this call will not necessarily have the same antithetic option as previous streams if this method is called in the interim. Note: This call only effects previously provided streams.

Link copied to clipboard
abstract fun streamNumber(stream: RNStreamIfc): Int