Class: TUniformRandomInteger

Declaration: RandomNumber.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TRandomInteger

Inherited By:

None.

Purpose:

Generates uniformly distributed random numbers.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

Derived classes must implement the constructors, the destructor, the member functions SetSeed, GetHighest, GetLowest, Next, and the streaming operators. Derived classes should produce uniform random generators in a different range and/or use a different pseudo-random algorithm. Additional member functions and data members may be required.

Concurrency:

Not multithread safe. Each object stores a single seed value, so that different threads using the same object interleave updates to the seed. This can be an issue for some derived classes that must generate reproducible sequences of random numbers. In this case, TRandomInteger objects cannot be shared by threads.

Resource Use:

No special requirements.

Other Considerations:

None.

Member Function: TUniformRandomInteger::TUniformRandomInteger

  1. TUniformRandomInteger (long initialSeed)
  2. TUniformRandomInteger ()

Interface Category:

API.

Purpose:

  1. Initializes the object's seed with the value initialSeed.
  2. Default constructor, initializes to a random value.

Calling Context:

  1. Called to construct a TUniformRandomInteger object with seed initialSeed.
  2. Called by the stream-in operators and to construct a TUniformRandomInteger object with a random seed.

Parameters:

Return Value:

None.

Exceptions:

Throws a TRandomException exception if initialSeed is not in range.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TUniformRandomInteger::~TUniformRandomInteger

virtual ~ TUniformRandomInteger ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TUniformRandomInteger::Next

virtual long Next ()

Interface Category:

API.

Purpose:

Generates the next value in a sequence of pseudo-random integers and updates the state of the object.

Calling Context:

Called to generate the next random value in a pseudo-random sequence of integers.

Parameters:

Return Value:

long -The next random value in a pseudo-random sequence of integers.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TUniformRandomInteger::GetSeed

virtual long GetSeed () const

Interface Category:

API.

Purpose:

Reads the value of the seed.

Calling Context:

Called to get the seed value.

Parameters:

Return Value:

long -The current value of the object's seed.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TUniformRandomInteger::SetSeed

virtual void SetSeed (long newSeed)

Interface Category:

API.

Purpose:

Changes the value of the seed to newSeed.

Calling Context:

Called to set the value of the seed to newSeed.

Parameters:

Return Value:

None.

Exceptions:

Throws a TRandomException exception if newSeed is not in range.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TUniformRandomInteger::GetHighestRandom

virtual long GetHighestRandom () const

Interface Category:

API.

Purpose:

Returns the largest random value that the generator can return.

Calling Context:

Called to get the value of the largest random number.

Parameters:

Return Value:

long kHighestRandom -The largest random value.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TUniformRandomInteger::GetLowestRandom

virtual long GetLowestRandom () const

Interface Category:

API.

Purpose:

Returns the lowest random value that the generator can return.

Calling Context:

Called to get the value of the lowest random number.

Parameters:

Return Value:

long kLowestRandom -The lowest random number.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TUniformRandomInteger::operator<<=

virtual TStream & operator <<= (TStream & fromwhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TUniformRandomInteger::operator>>=

virtual TStream & operator >>=(TStream & towhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.