SUMMARY:  INNER | FIELD | CONSTR | METHOD | FRIEND DETAIL:  FIELD | CONSTR | METHOD | FRIEND


Platform::Util::Random
Class IRandom

NonCopyableType
   |
   +-IRandom

Implemented in:
Platform.Util.Random.h
Direct Known Subclasses:
LinearCongruential, MersenneTwister

abstract class IRandom:
private NonCopyableType

A random number generator interface.

Field Summarycollapse
const Bool isDeterministic
          Tells whether the implementing class provides determenistic pseudo-random data.
const Bool isUniform
          Tells whether the implementing class provides uniform distribution of pseudo-random data.

Constructor Summarycollapse
IRandom(Bool uniform, Bool deterministic)
          Creates a new IRandom object.
~IRandom() = 0
          Destructor.

Method Summarycollapse
Bool nextBool()
          Returns a 1-bit integer number in interval [False .. True].
Double nextDouble()
          Returns a 64-bit floating-point number in interval [0.0 .. 1.0).
Float nextFloat()
          Returns a 32-bit floating-point number in interval [0.0 .. 1.0).
Double nextGaussianDistribution()
          Returns a 64-bit floating-point number in interval [0.0 .. 1.0).
Int nextInt()
          Returns a 32-bit integer number in interval [0 .. 2^32-1] with 2^32 bit resolution.
template <typename Type>
Type
nextLessThan(const Type& maxValue)
          Returns a number in interval [0 .. maxValue).
Long nextLong()
          Returns a 64-bit integer number in interval [0 .. 2^64-1] with 2^64 bit resolution.
Double nextNormalDistribution()
          Returns a 64-bit floating-point number in interval [0.0 .. 1.0).
template <typename Type>
Type
nextWithinRange(const Type& minValue, const Type& maxValue)
          Returns a number in interval [minValue .. maxValue).
protected UInt random() = 0
          Retrieves up to 32-bit of pseudo-random data.
Void seed(UInt value)
          Resets the IRandom interface.
template <typename Container>
Void
shuffle(Container& container)
          Randomly shuffle elements in a container.
template <typename Container,
typename ExchangerType>
Void
shuffle(Container& container, ExchangerType exchangeFn)
          Randomly shuffle elements in a container.
template <typename Type>
Void
shuffle(Type* array, Int size)
          Randomly shuffle elements of an array.
template <typename Type,
typename ExchangerType>
Void
shuffle(Type* array, Int size, ExchangerType exchangeFn)
          Randomly shuffle elements of an array.

Friend Summarycollapse
friend Io::ISerializer& operator<<(Io::ISerializer& serializer, const IRandom& object)
          Serializes the state of an IRandom object.
friend Io::IDeserializer& operator>>(Io::IDeserializer& deserializer, IRandom& object)
          Deserializes the state of an IRandom object.

 

Field Detail

isDeterministic

const Bool isDeterministic

Tells whether the implementing class provides determenistic pseudo-random data.


isUniform

const Bool isUniform

Tells whether the implementing class provides uniform distribution of pseudo-random data.

 

Constructor Detail

IRandom[inline]

IRandom(Bool uniform, Bool deterministic)

Creates a new IRandom object.

Parameters:
uniform - specifies whether the implementing class provides uniform distribution of pseudo-random data
deterministic - specifies whether the implementing class provides determenistic pseudo-random data

~IRandom[abstract, inline]

~IRandom() = 0

Destructor.

 

Method Detail

nextBool[inline]

Bool nextBool()

Returns a 1-bit integer number in interval [False .. True].

Returns:
a 1-bit integer number in interval [False .. True]

nextDouble[inline]

Double nextDouble()

Returns a 64-bit floating-point number in interval [0.0 .. 1.0).

Returns:
a 64-bit floating-point number in interval [0.0 .. 1.0)

nextFloat[inline]

Float nextFloat()

Returns a 32-bit floating-point number in interval [0.0 .. 1.0).

Returns:
a 32-bit floating-point number in interval [0.0 .. 1.0)

nextGaussianDistribution[inline]

Double nextGaussianDistribution()

Returns a 64-bit floating-point number in interval [0.0 .. 1.0). The returned value is subject to gaussian distribution (transforms uniform distribution into normal).

Returns:
a 64-bit floating-point number in interval [0.0 .. 1.0)

nextInt[inline]

Int nextInt()

Returns a 32-bit integer number in interval [0 .. 2^32-1] with 2^32 bit resolution.

Returns:
a 32-bit integer number in interval [0 .. 2^32-1] with 2^32 bit resolution

nextLessThan[inline]

template <typename Type>
Type nextLessThan(const Type& maxValue)

Returns a number in interval [0 .. maxValue).

Returns:
a number in interval [0 .. maxValue)

nextLong[inline]

Long nextLong()

Returns a 64-bit integer number in interval [0 .. 2^64-1] with 2^64 bit resolution.

Returns:
a 64-bit integer number in interval [0 .. 2^64-1] with 2^64 bit resolution

nextNormalDistribution[inline]

Double nextNormalDistribution()

Returns a 64-bit floating-point number in interval [0.0 .. 1.0). The returned value is subject to normal distribution (deterministic polar method using trigonometric functions).

Returns:
a 64-bit floating-point number in interval [0.0 .. 1.0)

nextWithinRange[inline]

template <typename Type>
Type nextWithinRange(const Type& minValue, const Type& maxValue)

Returns a number in interval [minValue .. maxValue).

Returns:
a number in interval [minValue .. maxValue)

random[abstract]

protected UInt random() = 0

Retrieves up to 32-bit of pseudo-random data.

Returns:
32-bit of pseudo-random data

seed[virtual, inline]

Void seed(UInt value)

Resets the IRandom interface. Subclasses should call this after seeding themselves.

Parameters:
value - seed value (formal parameter)

shuffle[inline]

template <typename Container>
Void shuffle(Container& container)

Randomly shuffle elements in a container.

Parameters:
container - a container

shuffle[inline]

template <typename Container, typename ExchangerType>
Void shuffle(Container& container, ExchangerType exchangeFn)

Randomly shuffle elements in a container.

Parameters:
container - a container
exchangeFn - element exchanger function

shuffle[inline]

template <typename Type>
Void shuffle(Type* array, Int size)

Randomly shuffle elements of an array.

Parameters:
array - an array
size - the size of the array

shuffle[inline]

template <typename Type, typename ExchangerType>
Void shuffle(Type* array, Int size, ExchangerType exchangeFn)

Randomly shuffle elements of an array.

Parameters:
array - an array
size - the size of the array
exchangeFn - element exchanger function

 

Friend Detail

operator<<[inline]

friend Io::ISerializer& operator<<(Io::ISerializer& serializer, const IRandom& object)

Serializes the state of an IRandom object.

Parameters:
object - an object to serialize
serializer - a serializer to receive state data
Returns:
the reference to the serializer

operator>>[inline]

friend Io::IDeserializer& operator>>(Io::IDeserializer& deserializer, IRandom& object)

Deserializes the state of an IRandom object.

Parameters:
object - an object to deserialize
deserializer - a deserializer to retrieve state data from
Returns:
the reference to the deserializer


SUMMARY:  INNER | FIELD | CONSTR | METHOD | FRIEND DETAIL:  FIELD | CONSTR | METHOD | FRIEND