|
tgen
|
Permutation value. More...

Public Member Functions | |
| value (const std::vector< int > &vec) | |
| Creates a permutation value from a std::vector. | |
| int | size () const |
| Returns the size of the permutation value. | |
| const int & | operator[] (int idx) const |
| Returns the image at some position of the permutation. | |
| int | parity () const |
| Parity of the permutation. | |
| value & | sort () |
| Sorts the permutation in non-decreasing order. | |
| value & | reverse () |
| Reverses the permutation. | |
| value & | inverse () |
| Inverse of the permutation. | |
| value & | separator (char sep) |
| Sets separator for printing. | |
| value & | add_1 () |
| Adds 1 for printing. | |
| value & | shuffle () |
| Shuffles the permutation. | |
| int | pick () const |
| Returns a uniformly random element. | |
| template<typename Dist> | |
| int | pick_by_distribution (const std::vector< Dist > &distribution) const |
| Returns a random element from the permutation with given probabilities. | |
| std::vector< int > | to_std () const |
| Converts the permutation 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 permutation to an output stream. | |
|
inline |
Creates a permutation value from a std::vector.
| vec | The std::vector representing the permutation. |
|
inline |
Adds 1 for printing.
This makes it so, when given to std::cout, the permutation will be printed as 1-based.
O(1).
|
inline |
Inverse of the permutation.
The inverse of the permutation p is another pi such that pi[p[i]] = p[pi[i]] = i.
O(n).
|
inline |
Returns the image at some position of the permutation.
| idx | Index to be accessed. |
|
inline |
Parity of the permutation.
|
inline |
Returns a uniformly random element.
O(1).
|
inline |
Returns a random element from the permutation with given probabilities.
| distribution | Probability distribution. |
O(1).
|
inline |
Reverses the permutation.
O(n).
|
inline |
Sets separator for printing.
O(1).
|
inline |
Shuffles the permutation.
O(n).
|
inline |
Returns the size of the permutation value.
|
inline |
Sorts the permutation in non-decreasing order.
O(n).
|
inline |
Converts the permutation to a std::vector.
|
friend |
Prints the permutation to an output stream.
The entries are printed with one space as a separator by default, and with no end of line.