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.
- TUniformRandomInteger (long initialSeed)
- TUniformRandomInteger ()
Interface Category:
API.
Purpose:
- Initializes the object's seed with the value initialSeed.
- Default constructor, initializes to a random value.
Calling Context:
- Called to construct a TUniformRandomInteger object with seed initialSeed.
- Called by the stream-in operators and to construct a TUniformRandomInteger object with a random seed.
Parameters:
- long initialSeed -The initial value of the seed.
- Takes no parameters.
Return Value:
None.
Exceptions:
Throws a TRandomException exception if initialSeed is not in range.
Concurrency:
Not multithread safe.
Other Considerations:
None.
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.
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.
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.
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:
- long newSeed -The new value of the seed.
Return Value:
None.
Exceptions:
Throws a TRandomException exception if newSeed is not in range.
Concurrency:
Not multithread safe.
Other Considerations:
None.
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.
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.
virtual TStream & operator <<= (TStream & fromwhere)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
Called to stream in data.
Parameters:
- TStream & fromwhere -The stream the object is streamed in from.
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.
virtual TStream & operator >>=(TStream & towhere) const
Interface Category:
API.
Purpose:
Stream-out operator.
Calling Context:
Called to stream out data.
Parameters:
- TStream & towhere -The stream the object is streamed out to.
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.