template<typename TEngine>
class gb::Random< TEngine >
Random number function creator.
- Template Parameters
-
◆ createCanonicalGenerator()
template<typename TEngine >
template<std::floating_point T>
| std::function<T()> gb::Random< TEngine >::createCanonicalGenerator |
( |
| ) |
|
|
inlinenoexcept |
Creates a random number generator function that generates floating point numbers [0, 1).
- Template Parameters
-
- Returns
- A function that generates random numbers in the range.
◆ createIntGenerator()
template<typename TEngine >
template<std::integral T>
| std::function<T()> gb::Random< TEngine >::createIntGenerator |
( |
T const |
low, |
|
|
T const |
high |
|
) |
| |
|
inlinenoexcept |
Creates a random number generator function that generates integer numbers [low, high].
- Template Parameters
-
- Parameters
-
| low | Range low boundary, inclusive. |
| high | Range high boundary, inclusive. |
- Returns
- A function that generates random numbers in the range.
◆ createFloatGenerator()
template<typename TEngine >
template<std::floating_point T>
| std::function<T()> gb::Random< TEngine >::createFloatGenerator |
( |
T const |
low, |
|
|
T const |
high |
|
) |
| |
|
inlinenoexcept |
Creates a random number generator function that generates floating point numbers [low, high).
- Template Parameters
-
- Parameters
-
| low | Range low boundary, inclusive. |
| high | Range high boundary, exclusive. |
- Returns
- A function that generates random numbers in the range.
◆ createContainerIndexGenerator()
template<typename TEngine >
template<HasSize TContainer>
| std::function<size_t()> gb::Random< TEngine >::createContainerIndexGenerator |
( |
TContainer const & |
container | ) |
|
|
inlinenoexcept |
This is a convenience method that creates a random number generator function that generates an integer in the range of the container indexes.
If container is empty, behavior is undefined. Don't call with an empty container!
- Template Parameters
-
| TContainer | Container type. |
- Parameters
-
| container | The container from which to get the index range. |
- Returns
- A function that generates random numbers in the range.
◆ pickFromContainer() [1/3]
template<typename TEngine >
template<IndexableContainer TContainer>
| TContainer::value_type& gb::Random< TEngine >::pickFromContainer |
( |
TContainer & |
container | ) |
|
|
inlinenoexcept |
This is a convenience method to pick a random item from a container.
If container is empty, behavior is undefined. Don't call with an empty container!
- Template Parameters
-
| TContainer | Container type. |
- Parameters
-
| container | The container from which to pick an item. |
- Returns
- A reference to the randomly picked item.
◆ pickFromContainer() [2/3]
template<typename TEngine >
template<class TContainer >
This is a convenience method to pick a random item from a container.
This template is for non-const default iterator.
If container is empty, behavior is undefined. Don't call with an empty container!
- Template Parameters
-
| TContainer | Container type. |
- Parameters
-
| container | The container from which to pick an item. |
- Returns
- A reference to the randomly picked item.
◆ pickFromContainer() [3/3]
template<typename TEngine >
template<class TContainer >
This is a convenience method to pick a random item from a container.
This template is for const default iterator.
If container is empty, behavior is undefined. Don't call with an empty container!
- Template Parameters
-
| TContainer | Container type. |
- Parameters
-
| container | The container from which to pick an item. |
- Returns
- A reference to the randomly picked item.
◆ pickIndexFromWeightedProbability() [1/2]
template<typename TEngine >
template<Numeric TWP, size_t N>
| size_t gb::Random< TEngine >::pickIndexFromWeightedProbability |
( |
const TWP(&) |
wps[N] | ) |
|
|
inlinenoexcept |
Picks a random index given ordered weighted probabilities.
- Template Parameters
-
| TWP | Weighted probability type. |
| N | Number of weights. |
- Parameters
-
| wps | Weighted probabilities. |
- Returns
- A random index.
◆ pickIndexFromWeightedProbability() [2/2]
template<typename TEngine >
template<class TContainer >
Picks a random index given ordered weighted probabilities.
- Template Parameters
-
| TContainer | Container type. |
- Parameters
-
| wps | Weighted probabilities. |
- Returns
- A random index.
◆ pickIndexFromNormalizedWeightedProbability() [1/2]
template<typename TEngine >
template<Numeric TWP, size_t N>
| size_t gb::Random< TEngine >::pickIndexFromNormalizedWeightedProbability |
( |
const TWP(&) |
wps[N] | ) |
|
|
inlinenoexcept |
Picks a random index given ordered weighted probabilities.
This version accepts zeroes and negative values, and normalizes values to be able to pick an index.
- Template Parameters
-
| TWP | Weighted probability type. |
| N | Number of weights. |
- Parameters
-
| wps | Weighted probabilities. |
- Returns
- A random index.
◆ pickIndexFromNormalizedWeightedProbability() [2/2]
template<typename TEngine >
template<class TContainer >
Picks a random index given ordered weighted probabilities.
This version accepts zeroes and negative values, and normalizes values to be able to pick an index.
- Template Parameters
-
| TContainer | Container type. |
- Parameters
-
| wps | Weighted probabilities. |
- Returns
- A random index.
The documentation for this class was generated from the following file: