GaRandomBool
class generates random boolean values. It supports generating boolean with defined probabilities of true
and false
states. The class implements GaRandom interface. This class has no built-in synchronizator, so LOCK_OBJECT
and LOCK_THIS_OBJECT
macros cannot be used with instances of this class, but all public methods are thread-safe.
More...
#include <D:/Temp/vs/gal/source/Random.h>
Inherits Common::GaRandom< bool >.
Public Member Functions | |
GaRandomBool () | |
This constructor initializes random generator with current time as seed. | |
GaRandomBool (unsigned long seed) | |
This constructor initialize random generator with user-defined seed. | |
virtual bool GACALL | Generate () |
This method generates random Boolean values. | |
virtual bool GACALL | Generate (const bool &max) |
This method generates random Boolean values. | |
virtual bool GACALL | Generate (const bool &min, const bool &max) |
This method generates random Boolean values. | |
bool GACALL | Generate (double p) |
This method generates Boolean value with p probability of true value. | |
bool GACALL | Generate (int p) |
This method generates Boolean value with p probability of true and 100-p of false value. | |
Private Attributes | |
GaRandomGenerator | _generator |
Instance of algorithm for generating random numbers. |
GaRandomBool
class generates random boolean values. It supports generating boolean with defined probabilities of true
and false
states. The class implements GaRandom interface. This class has no built-in synchronizator, so LOCK_OBJECT
and LOCK_THIS_OBJECT
macros cannot be used with instances of this class, but all public methods are thread-safe.
Common::GaRandomBool::GaRandomBool | ( | ) | [inline] |
This constructor initializes random generator with current time as seed.
Common::GaRandomBool::GaRandomBool | ( | unsigned long | seed | ) | [inline] |
This constructor initialize random generator with user-defined seed.
seed | user-defined seed. |
virtual bool GACALL Common::GaRandomBool::Generate | ( | ) | [inline, virtual] |
This method generates random Boolean values.
This method is thread-safe.
Implements Common::GaRandom< bool >.
virtual bool GACALL Common::GaRandomBool::Generate | ( | const bool & | max | ) | [inline, virtual] |
This method generates random Boolean values.
This method is thread-safe.
max | this parameter is ignored. |
Implements Common::GaRandom< bool >.
virtual bool GACALL Common::GaRandomBool::Generate | ( | const bool & | min, | |
const bool & | max | |||
) | [inline, virtual] |
This method generates random Boolean values.
This method is thread-safe.
min | this parameter is ignored. | |
max | this parameter is ignored. |
Implements Common::GaRandom< bool >.
bool GACALL Common::GaRandomBool::Generate | ( | double | p | ) | [inline] |
This method generates Boolean value with p
probability of true
value.
This method is thread safe.
p | probability of true value (0, 1). |
bool GACALL Common::GaRandomBool::Generate | ( | int | p | ) | [inline] |
This method generates Boolean value with p
probability of true
and 100-p
of false
value.
This method is thread safe.
p | probability in percents of true value (0 - 100). |
Instance of algorithm for generating random numbers.