A simple pseudo-random number generator. More...
Public Member Functions | |
| Random (int64 seedValue) throw () | |
| Creates a Random object based on a seed value. | |
| ~Random () throw () | |
| Destructor. | |
| int | nextInt () throw () |
| Returns the next random 32 bit integer. | |
| int | nextInt (int maxValue) throw () |
| Returns the next random number, limited to a given range. | |
| int64 | nextInt64 () throw () |
| Returns the next 64-bit random number. | |
| float | nextFloat () throw () |
| Returns the next random floating-point number. | |
| double | nextDouble () throw () |
| Returns the next random floating-point number. | |
| bool | nextBool () throw () |
| Returns the next random boolean value. | |
| const BigInteger | nextLargeNumber (const BigInteger &maximumValue) |
| Returns a BigInteger containing a random number. | |
| void | fillBitsRandomly (BigInteger &arrayToChange, int startBit, int numBits) |
| Sets a range of bits in a BigInteger to random values. | |
| void | setSeed (int64 newSeed) throw () |
| Resets this Random object to a given seed value. | |
| void | combineSeed (int64 seedValue) throw () |
| Merges this object's seed with another value. | |
| void | setSeedRandomly () |
| Reseeds this generator using a value generated from various semi-random system properties like the current time, etc. | |
Static Public Member Functions | |
| static Random & | getSystemRandom () throw () |
| To avoid the overhead of having to create a new Random object whenever you need a number, this is a shared application-wide object that can be used. | |
A simple pseudo-random number generator.
| Random::Random | ( | int64 | seedValue | ) | throw () [explicit] |
Creates a Random object based on a seed value.
For a given seed value, the subsequent numbers generated by this object will be predictable, so a good idea is to set this value based on the time, e.g.
| Random::~Random | ( | ) | throw () |
Destructor.
| int Random::nextInt | ( | ) | throw () |
Returns the next random 32 bit integer.
| int Random::nextInt | ( | int | maxValue | ) | throw () |
Returns the next random number, limited to a given range.
| int64 Random::nextInt64 | ( | ) | throw () |
Returns the next 64-bit random number.
| float Random::nextFloat | ( | ) | throw () |
Returns the next random floating-point number.
| double Random::nextDouble | ( | ) | throw () |
Returns the next random floating-point number.
| bool Random::nextBool | ( | ) | throw () |
Returns the next random boolean value.
| const BigInteger Random::nextLargeNumber | ( | const BigInteger & | maximumValue | ) |
Returns a BigInteger containing a random number.
| void Random::fillBitsRandomly | ( | BigInteger & | arrayToChange, | |
| int | startBit, | |||
| int | numBits | |||
| ) |
Sets a range of bits in a BigInteger to random values.
| static Random& Random::getSystemRandom | ( | ) | throw () [static] |
To avoid the overhead of having to create a new Random object whenever you need a number, this is a shared application-wide object that can be used.
It's not thread-safe though, so threads should use their own Random object.
Referenced by juce_getOutputFromCommand().
| void Random::combineSeed | ( | int64 | seedValue | ) | throw () |
Merges this object's seed with another value.
This sets the seed to be a value created by combining the current seed and this new value.
| void Random::setSeedRandomly | ( | ) |
Reseeds this generator using a value generated from various semi-random system properties like the current time, etc.
Because this function convolves the time with the last seed value, calling it repeatedly will increase the randomness of the final result.
1.6.3