|
tgen
|
List generator. More...

Classes | |
| struct | value |
| List value. More... | |
Public Member Functions | |
| list (int size, T value_left, T value_right) | |
| Creates list generator defined by size and range of values. | |
| list (int size, std::set< T > values) | |
| Creates list generator defined by value set. | |
| list & | fix (int idx, T val) |
| Restricts generator s.t. value at index is fixed. | |
| list & | equal (int idx_1, int idx_2) |
| Restricts generator s.t. values at two indices are equal. | |
| list & | equal (std::set< int > indices) |
| Restricts generator s.t. all values in index set are equal. | |
| list & | equal_range (int left, int right) |
| Restricts generator s.t. all values at index range are equal. | |
| list & | all_equal () |
| Restricts generator s.t. all values are equal. | |
| list & | different (std::set< int > indices) |
| Restricts generator s.t. all values in index set are different. | |
| list & | different (int idx_1, int idx_2) |
| Restricts generator s.t. values at two indices are different. | |
| list & | different_range (int left, int right) |
| Restricts generator s.t. all values at index range are different. | |
| list & | all_different () |
| Restricts generator s.t. all values are different. | |
| value | gen () const |
| Generates a random value from the set of valid lists. | |
| Public Member Functions inherited from tgen::gen_base< list< 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 value from the valid set until a condition is met. | |
| auto | distinct (Args &&...args) const |
| Creates distinct generator for current generator. | |
List generator.
Defines a set of lists, subject to restrictions.
A uniformly random tgen::list::value from this set of lists (that satisfies the restrictions) can be generated with tgen::list::gen.
|
inline |
Creates list generator defined by size and range of values.
| T | Integral type to be stored in the list. |
| size | Size of the list. |
| value_left | Left endpoint of value range. |
| value_right | Right endpoint of value range. |
Defines a generator of lists of length size with values in [value_left, value_right].
|
inline |
Creates list generator defined by value set.
| T | Integral type to be stored in the list. |
| size | Size of the list. |
| values | Value set. |
Defines a generator of lists of length size with values in values.
|
inline |
Restricts generator s.t. all values are different.
Equivalent to tgen::list::different({0, 1, ... size-1}).
|
inline |
Restricts generator s.t. all values are equal.
Equivalent to tgen::list::equal({0, 1, ... size-1}).
|
inline |
Restricts generator s.t. values at two indices are different.
| idx_1 | First index. |
| idx_2 | Second index. |
Equivalent to tgen::list::different({idx_1, idx_2}).
|
inline |
Restricts generator s.t. all values in index set are different.
| indices | Index set. |
| std::runtime_error | if generation fails. |
|
inline |
Restricts generator s.t. all values at index range are different.
| left | Left endpoint of index range (inclusive). |
| right | Right endpoint of index range (inclusive). |
Equivalent to tgen::list::different({left, left+1, ... , right}).
|
inline |
Restricts generator s.t. values at two indices are equal.
| idx_1 | First index. |
| idx_2 | Second index. |
Equivalent to tgen::list::equal({idx_1, idx_2}).
|
inline |
|
inline |
Restricts generator s.t. all values at index range are equal.
| left | Left endpoint of index range (inclusive). |
| right | Right endpoint of index range (inclusive). |
Equivalent to tgen::list::equal({left, left+1, ... , right}).
|
inline |
Restricts generator s.t. value at index is fixed.
| idx | Index. |
| val | Value. |
| std::runtime_error | if value is not in the value range/set. |
|
inline |
Generates a random value from the set of valid lists.
| std::runtime_error | if there is no valid list satisfying all added restrictions, or if the added restrictions are considered to be too complex (see tgen::list::different). |
O(n log n).