|
tgen
|
Sequence generator. More...

Classes | |
| struct | instance |
| Sequence instance. More... | |
Public Member Functions | |
| sequence (int size, T value_l, T value_r) | |
| Creates sequence generator define by size and range of values. | |
| sequence (int size, std::set< T > values) | |
| Creates sequence generator define by value set. | |
| sequence & | fix (int idx, T value) |
| Restricts generator s.t. value at index is fixed. | |
| sequence & | equal (int idx_1, int idx_2) |
| Restricts generator s.t. values at two indices are the same. | |
| sequence & | equal_range (int left, int right) |
| Restricts generator s.t. all values at index range are the same. | |
| sequence & | distinct (std::set< int > indices) |
| Restricts generator s.t. all values in index set are distinct. | |
| sequence & | different (int idx_1, int idx_2) |
| Restricts generator s.t. values at two indices are different. | |
| sequence & | distinct () |
| Restricts generator s.t. all values are distinct. | |
| instance | gen () const |
| Generates a random instance from the set of valid sequences. | |
| Public Member Functions inherited from tgen::gen_base< sequence< T > > | |
| auto | gen_list (int size, Args &&...args) const |
| Generates a list of several generation calls. | |
| auto | gen_until (Pred predicate, int max_tries, Args &&...args) const |
| Generates a random instance from the valid set until a condition is met. | |
| auto | unique (Args &&...args) const |
| Creates unique generator for current generator. | |
Sequence generator.
Defines a set of sequences, subject to restrictions.
A uniformly random tgen::sequence::instance from this set of sequences (that satisfies the restrictions) can be generated with tgen::sequence::gen.
|
inline |
Creates sequence generator define by size and range of values.
| size | Size of the sequence. |
| value_l | Left endpoint of value range. |
| value_r | Right endpoint of value range. |
Defines a generator of sequences of length size with values in [value_l, value_r].
|
inline |
Creates sequence generator define by value set.
| size | Size of the sequence. |
| values | Value set. |
Defines a generator of sequences of length size with values in values.
|
inline |
Restricts generator s.t. values at two indices are different.
| idx_1 | First index. |
| idx_2 | Second index. |
Equivalent to tgen::sequence::distinct({idx_1, idx_2}).
|
inline |
Restricts generator s.t. all values are distinct.
Equivalent to tgen::sequence::distinct({0, 1, ... size-1}).
|
inline |
Restricts generator s.t. all values in index set are distinct.
| indices | Index set. |
| std::runtime_error | if generation fails. |
|
inline |
Restricts generator s.t. values at two indices are the same.
| idx_1 | First index. |
| idx_2 | Second index. |
|
inline |
Restricts generator s.t. all values at index range are the same.
| left | Left endpoint of index range (inclusive). |
| right | Right endpoint of index range (inclusive). |
|
inline |
Restricts generator s.t. value at index is fixed.
| idx | Index. |
| value | Value. |
| std::runtime_error | if value is not in the value range/set. |
|
inline |
Generates a random instance from the set of valid sequences.
| std::runtime_error | if there is no valid sequence satisfying all added restrictions, or if the added restrictions are considered to be too complex (see tgen::sequence::distinct). |
O(n log n).