Operations for tgen generator values.
More...
|
| template<typename Inst, std::enable_if_t< is_sequential< Inst >::value, int > = 0> |
| void | tgen::shuffle (Inst &inst) |
| | Shuffles a list value.
|
| template<typename Inst, std::enable_if_t< is_sequential< Inst >::value, int > = 0> |
| Inst | tgen::shuffled (const Inst &inst) |
| | Shuffles a list value.
|
| template<typename Inst, std::enable_if_t< is_sequential< Inst >::value, int > = 0> |
| Inst::value_type | tgen::pick (const Inst &inst) |
| | Choses a random element from the list value.
|
| template<typename Inst, typename T, std::enable_if_t< is_sequential< Inst >::value, int > = 0> |
| Inst::value_type | tgen::pick_by_distribution (const Inst &inst, const std::vector< T > &distribution) |
| | Choses a random element from the list value.
|
| template<typename Inst, std::enable_if_t< is_sequential< Inst >::value and has_subset_defined< Inst >::value, int > = 0> |
| Inst | tgen::choose (const Inst &inst, int k) |
| | Chooses some values from the list value, as in a sublist of fixed length.
|
Operations for tgen generator values.
Examples
It::value_type pick(It first, It last)
Choses a random element from iterator range.
auto shuffled(const C &container)
Shuffles a container.
◆ choose()
| Inst tgen::choose |
( |
const Inst & | inst, |
|
|
int | k ) |
Chooses some values from the list value, as in a sublist of fixed length.
- Template Parameters
-
- Parameters
-
| inst | The original value. |
| k | The size of the sublist. |
- Returns
- A uniformly random subsequence of length k.
Complexity
O(|inst|).
Examples
C choose(const C &container, int k)
Chooses elements from container, as in a subsequence fixed length.
Definition at line 772 of file tgen.h.
◆ pick()
template<typename Inst, std::enable_if_t<
is_sequential< Inst >::value, int > = 0>
| Inst::value_type tgen::pick |
( |
const Inst & | inst | ) |
|
Choses a random element from the list value.
- Template Parameters
-
- Parameters
-
- Returns
- A uniformly random element from the value.
Complexity
O(1).
Examples
Definition at line 691 of file tgen.h.
◆ pick_by_distribution()
template<typename Inst, typename T, std::enable_if_t<
is_sequential< Inst >::value, int > = 0>
| Inst::value_type tgen::pick_by_distribution |
( |
const Inst & | inst, |
|
|
const std::vector< T > & | distribution ) |
Choses a random element from the list value.
- Template Parameters
-
- Parameters
-
| inst | The value to choose from. |
| distribution | The probability distribution. |
- Returns
- A uniformly random element from the value.
Complexity
O(1).
Examples
C::value_type pick_by_distribution(const C &container, std::vector< T > distribution)
Choses a random element with given probabilities.
Definition at line 731 of file tgen.h.
◆ shuffle()
template<typename Inst, std::enable_if_t<
is_sequential< Inst >::value, int > = 0>
| void tgen::shuffle |
( |
Inst & | inst | ) |
|
Shuffles a list value.
- Template Parameters
-
- Parameters
-
| inst | The value to shuffle. |
Complexity
O(|inst|).
Examples
void shuffle(It first, It last)
Shuffles range inplace, for random_access_iterator.
Definition at line 635 of file tgen.h.
◆ shuffled()
template<typename Inst, std::enable_if_t<
is_sequential< Inst >::value, int > = 0>
| Inst tgen::shuffled |
( |
const Inst & | inst | ) |
|
|
nodiscard |
Shuffles a list value.
- Template Parameters
-
- Parameters
-
- Returns
- The shuffled value.
Complexity
O(|inst|).
Examples
Definition at line 663 of file tgen.h.