|
tgen 1.4.0
|
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 & | print_1_based () |
| Sets that printed values are 1-based. | |
| 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. | |
| std::vector< int > | to_std_1_based () const |
| Converts the permutation to a 1-based 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 |
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 |
Sets that printed values are 1-based.
This only affects streaming (std::cout and friends). Stored values, operator[], and to_std() stay 0-based. For a 1-based std::vector, use to_std_1_based().
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.
Returns 0-based values. Unaffected by print_1_based(). For a 1-based export, use to_std_1_based().
|
inline |
Converts the permutation to a 1-based std::vector.
Each element is increased by one. Unaffected by print_1_based().
|
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.