tgen
Loading...
Searching...
No Matches
Sequence operations

Random operations on sequence instances. More...

Functions

template<typename Inst, std::enable_if_t< _detail::is_generator_instance< Inst >::value, int > = 0>
Inst tgen::shuffled (const Inst &inst)
 Shuffles a sequence instance.
template<typename Inst, std::enable_if_t< _detail::is_generator_instance< Inst >::value, int > = 0>
Inst::value_type tgen::any (const Inst &inst)
 Choses a random element from the sequence instance.
template<typename Inst, std::enable_if_t< _detail::is_generator_instance< 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.

Detailed Description

Random operations on sequence instances.

These operations make random decisions.

Function Documentation

◆ any()

template<typename Inst, std::enable_if_t< _detail::is_generator_instance< Inst >::value, int > = 0>
Inst::value_type tgen::any ( const Inst & inst)

Choses a random element from the sequence instance.

Template Parameters
InstSequence instance type, deduced automatically. Must be a tgen::sequence::instance.
Parameters
instthe original instance.
Returns
A uniformly random element from the instance.

Complexity

O(1).

Examples

// Prints a random element from v.
std::cout <<
tgen::any(inst) << std::endl;
It::value_type any(It first, It last)
Choses a random element from iterator range.
Definition tgen.h:359
Sequence instance.
Definition tgen.h:721

Definition at line 382 of file tgen.h.

◆ choose()

template<typename Inst, std::enable_if_t< _detail::is_generator_instance< 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.

Template Parameters
InstSequence instance type, deduced automatically. Must be a tgen::sequence::instance.
Parameters
kThe size of the subsequence.
instthe original instance.
Returns
A uniformly random subsequence of length k.

Complexity

O(|inst|).

Examples

// Prints a subsequenec of length 2 from v.
std::cout <<
tgen::choose(2, inst) << std::endl;
C choose(int k, const C &container)
Chooses elements from container, as in a subsequence fixed length.
Definition tgen.h:390

Definition at line 415 of file tgen.h.

◆ shuffled()

template<typename Inst, std::enable_if_t< _detail::is_generator_instance< Inst >::value, int > = 0>
Inst tgen::shuffled ( const Inst & inst)

Shuffles a sequence instance.

Template Parameters
InstSequence instance type, deduced automatically. Must be a tgen::sequence::instance.
Parameters
instthe original instance.
Returns
The shuffled instance.

Complexity

O(|inst|).

Examples

// Shuffles and prints an instance.
std::cout <<
tgen::shuffle(inst) << std::endl;
void shuffle(It first, It last)
Shuffles range inplace, for random_access_iterator.
Definition tgen.h:316

Definition at line 351 of file tgen.h.