com.newisys.random
Interface PRNGProvider

All Superinterfaces:
Cloneable, Serializable
All Known Subinterfaces:
PRNG

public interface PRNGProvider
extends Serializable, Cloneable

Basic interface for a pseudorandom number generator. It allows PRNG implementors to focus on the core functionality (i.e. providing a serializable, cloneable stream of random bits) and use PRNGWrapper to generically implement the remaining PRNG methods.


Method Summary
 PRNGProvider clone()
          Returns a new instance of this generator with the same state, meaning that each instance will independently generate the same sequence.
 int nextBits(int bits)
          Returns an int containing the given number of random bits.
 void nextInts(int[] array, int start, int count)
          Fills the given array with random ints, as if nextBits(32) were called for each element.
 

Method Detail

nextBits

int nextBits(int bits)
Returns an int containing the given number of random bits. Some random number generators will produce a fixed number of random bits each time this method is called, and discard any unneeded bits, so it may not be efficient to call this method repeatedly for a small number of bits.

Parameters:
bits - the number of random bits requested, which must be greater than or equal to zero
Returns:
a random int less than (1 << bits)

nextInts

void nextInts(int[] array,
              int start,
              int count)
Fills the given array with random ints, as if nextBits(32) were called for each element.

Parameters:
array - the array to fill
start - the starting index to fill
count - the number of elements to fill, which must be greater than or equal to zero

clone

PRNGProvider clone()
Returns a new instance of this generator with the same state, meaning that each instance will independently generate the same sequence.

Returns:
a clone of this PRNGProvider