The Random class provides wrappers around base 'random' functionality, such as getting a number within a given range, shuffling elements, or filling an array with large amounts of random data. This class assumes psuedo-randomness is sufficient and that performance is more important, and thus should not be used where unpredictability or uniform distribution is desired.
More...
#include <Random.hpp>
|
| template<typename T , typename URBG > |
| static T | inRange (T const min, T const max, URBG &&rng) noexcept |
| | Get a random number within the given range. The distribution may not be uniform. More...
|
| |
| template<typename T , typename URBG > |
| static void | fillWithRange (T *const data, size_t const num, T const min, T const max, URBG &&rng) noexcept |
| | Fill a container with random numbers. If min and max are the same, an optimization is used where random is never called. If min is greater than max, the behavior is undefined (very bad). More...
|
| |
| template<typename T , typename URBG > |
| static void | fillWithPerm (T *const data, size_t const num, T const offset, URBG &&rng) noexcept |
| | Fill a memory location with a permutation vector. More...
|
| |
| template<typename T , typename URBG > |
| static void | pseudoShuffle (T *const data, size_t const num, URBG &&rng) noexcept |
| | Re-order the elements in array in a randomly. This is less random than std::shuffle, but is significantly faster for large arrays. More...
|
| |
The Random class provides wrappers around base 'random' functionality, such as getting a number within a given range, shuffling elements, or filling an array with large amounts of random data. This class assumes psuedo-randomness is sufficient and that performance is more important, and thus should not be used where unpredictability or uniform distribution is desired.
◆ fillWithPerm()
template<typename T , typename URBG >
| static void sl::Random::fillWithPerm |
( |
T *const |
data, |
|
|
size_t const |
num, |
|
|
T const |
offset, |
|
|
URBG && |
rng |
|
) |
| |
|
inlinestaticnoexcept |
Fill a memory location with a permutation vector.
- Template Parameters
-
| T | The type of data. |
| URBG | The type of random source. |
- Parameters
-
| data | The range of elements to fill. |
| begin | The starting index. |
◆ fillWithRange()
template<typename T , typename URBG >
| static void sl::Random::fillWithRange |
( |
T *const |
data, |
|
|
size_t const |
num, |
|
|
T const |
min, |
|
|
T const |
max, |
|
|
URBG && |
rng |
|
) |
| |
|
inlinestaticnoexcept |
Fill a container with random numbers. If min and max are the same, an optimization is used where random is never called. If min is greater than max, the behavior is undefined (very bad).
- Template Parameters
-
| T | The type of iterator. |
| URBG | The type of random source. |
- Parameters
-
| range | The range of elements to fill. |
| min | The minimum number (inclusive). |
| max | The maximum number (exclusive). |
| rng | The random source. |
◆ inRange()
template<typename T , typename URBG >
| static T sl::Random::inRange |
( |
T const |
min, |
|
|
T const |
max, |
|
|
URBG && |
rng |
|
) |
| |
|
inlinestaticnoexcept |
Get a random number within the given range. The distribution may not be uniform.
- Template Parameters
-
| T | The type of random source. |
| URBG | The random source. |
- Parameters
-
| min | The lower bound (inclusive). |
| max | The upper bound (exclusive). |
| rng | The random source. |
◆ pseudoShuffle()
template<typename T , typename URBG >
| static void sl::Random::pseudoShuffle |
( |
T *const |
data, |
|
|
size_t const |
num, |
|
|
URBG && |
rng |
|
) |
| |
|
inlinestaticnoexcept |
Re-order the elements in array in a randomly. This is less random than std::shuffle, but is significantly faster for large arrays.
- Template Parameters
-
| T | The type of elements. |
| URBG | The type of random source. |
- Parameters
-
| data | The data to shuffle. |
| num | The number of elements. |
| rng | The random source. |
The documentation for this class was generated from the following file: