|
tgen
|
List value. More...

Public Member Functions | |
| value (const std::vector< T > &vec) | |
| Creates a list value from a std::vector. | |
| int | size () const |
| Returns the size of the list value. | |
| T & | operator[] (int idx) |
| Accesses the element at some position of the list. | |
| value & | sort () |
| Sorts the list in non-decreasing order. | |
| value & | reverse () |
| Reverses the list. | |
| value & | separator (char sep) |
| Sets separator for printing. | |
| value | operator+ (const value &rhs) const |
| Concatenates two lists. | |
| value & | shuffle () |
| Shuffles the list in place. | |
| T | pick () const |
| Returns a uniformly random element. | |
| template<typename Dist> | |
| T | pick_by_distribution (const std::vector< Dist > &distribution) const |
| Returns a random element from the list with given probabilities. | |
| value | choose (int k) const |
| Chooses a uniformly random subsequence of given length. | |
| auto | to_std () const |
| Converts the list to a std::vector. | |
| Public Member Functions inherited from tgen::gen_value_base< value > | |
| bool | operator< (const value &rhs) const |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const value &val) |
| Prints the list to an output stream. | |
List value.
It can be printed through std::cout.
|
inline |
Creates a list value from a std::vector.
| vec | The std::vector representing the list. |
|
inline |
Chooses a uniformly random subsequence of given length.
| k | Subsequence length. |
O(n).
|
inline |
Concatenates two lists.
| rhs | The right-hand side. |
Linear.
|
inline |
Accesses the element at some position of the list.
| idx | Index to be accessed. |
|
inline |
Returns a uniformly random element.
O(1).
|
inline |
Returns a random element from the list with given probabilities.
| distribution | Probability distribution. |
Also works with std::initializer_list for distribution.
O(1).
|
inline |
Reverses the list.
O(n).
|
inline |
Sets separator for printing.
O(1).
|
inline |
Shuffles the list in place.
O(n).
|
inline |
Returns the size of the list value.
|
inline |
Sorts the list in non-decreasing order.
O(n log n).
|
inline |
Converts the list to a std::vector.
to_std() is called recursevely on type T, if it applies.
|
friend |