Operations for tgen generator instances.
More...
|
| template<typename Inst, std::enable_if_t< is_sequential< Inst >::value, int > = 0> |
| void | tgen::shuffle (Inst &inst) |
| | Shuffles a sequence instance.
|
| template<typename Inst, std::enable_if_t< is_sequential< Inst >::value, int > = 0> |
| Inst | tgen::shuffled (const Inst &inst) |
| | Shuffles a sequence instance.
|
| template<typename Inst, std::enable_if_t< is_sequential< Inst >::value, int > = 0> |
| Inst::value_type | tgen::any (const Inst &inst) |
| | Choses a random element from the sequence instance.
|
| template<typename Inst, typename T, std::enable_if_t< is_sequential< Inst >::value, int > = 0> |
| Inst::value_type | tgen::any_by_distribution (const Inst &inst, const std::vector< T > &distribution) |
| | Choses a random element from the sequence instance.
|
| template<typename Inst, std::enable_if_t< is_sequential< Inst >::value and has_subset_defined< Inst >::value, int > = 0> |
| Inst | tgen::choose (int k, const Inst &inst) |
| | Chooses some values from the sequence instance, as in a subsequence of fixed length.
|
Operations for tgen generator instances.
Examples
◆ any()
template<typename Inst, std::enable_if_t<
is_sequential< Inst >::value, int > = 0>
| Inst::value_type tgen::any |
( |
const Inst & | inst | ) |
|
Choses a random element from the sequence instance.
- Template Parameters
-
- Parameters
-
| inst | The original instance. |
- Returns
- A uniformly random element from the instance.
Complexity
O(1).
Examples
It::value_type any(It first, It last)
Choses a random element from iterator range.
Definition at line 645 of file tgen.h.
◆ any_by_distribution()
template<typename Inst, typename T, std::enable_if_t<
is_sequential< Inst >::value, int > = 0>
| Inst::value_type tgen::any_by_distribution |
( |
const Inst & | inst, |
|
|
const std::vector< T > & | distribution ) |
Choses a random element from the sequence instance.
- Template Parameters
-
- Parameters
-
| inst | The instance to choose from. |
| distribution | The probability distribution. |
- Returns
- A uniformly random element from the instance.
Complexity
O(1).
Examples
C::value_type any_by_distribution(const C &container, std::vector< T > distribution)
Choses a random element with given probabilities.
Definition at line 685 of file tgen.h.
◆ choose()
| Inst tgen::choose |
( |
int | k, |
|
|
const Inst & | inst ) |
Chooses some values from the sequence instance, as in a subsequence of fixed length.
- Template Parameters
-
- Parameters
-
| k | The size of the subsequence. |
| inst | The original instance. |
- Returns
- A uniformly random subsequence of length k.
Complexity
O(|inst|).
Examples
C choose(int k, const C &container)
Chooses elements from container, as in a subsequence fixed length.
Definition at line 727 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 sequence instance.
- Template Parameters
-
- Parameters
-
| inst | The instance to shuffle. |
Complexity
O(|inst|).
Examples
void shuffle(It first, It last)
Shuffles range inplace, for random_access_iterator.
Definition at line 587 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 sequence instance.
- Template Parameters
-
- Parameters
-
| inst | The original instance. |
- Returns
- The shuffled instance.
Complexity
O(|inst|).
Examples
C shuffled(const C &container)
Shuffles a container.
Definition at line 616 of file tgen.h.