CMR
1.3.0
|
#include <permutations.hpp>
Public Types | |
typedef size_t | size_type |
typedef ptrdiff_t | difference_type |
typedef size_t | value_type |
typedef std::vector< value_type > | data_type |
Public Member Functions | |
permutation (size_type size=0) | |
template<typename RandomNumberGenerator > | |
permutation (size_type size, RandomNumberGenerator &rng) | |
permutation (const permutation &other) | |
virtual | ~permutation () |
void | reset (size_t new_size) |
void | reset () |
template<typename RandomNumberGenerator > | |
void | shuffle (RandomNumberGenerator &rng) |
size_type | size () const |
value_type | operator() (value_type index) const |
value_type | get (value_type index) const |
void | swap (value_type a, value_type b) |
void | rswap (value_type a, value_type b) |
void | revert () |
permutation | reverse () const |
permutation & | operator= (const permutation &other) |
permutation | operator* (const permutation &rhs) const |
void | resize (size_type new_size) |
void | grow (difference_type by) |
void | shrink (difference_type by) |
Protected Member Functions | |
void | _set (value_type index, value_type value) |
data_type & | get_data () |
Protected Attributes | |
data_type | _data |
Friends | |
class | permutation_enumerator |
Class to enumerate permutations. More... | |
template<class Less > | |
void | sort (permutation &permutation, size_t first, size_t beyond, Less &less) |
Class to setup a permutation which can be put before a vector. More... | |
A permutation which maps integers from 0 to size-1 to the same range in any possible way. This implementation stores the image of each of the values in a vector.
typedef std::vector<value_type> tu::permutation::data_type |
typedef ptrdiff_t tu::permutation::difference_type |
typedef size_t tu::permutation::size_type |
typedef size_t tu::permutation::value_type |
|
inline |
Constructs a permutation of a given size, initializing to the identity.
size | Optional size of the permutation |
|
inline |
Constructs a permutation of a given size, initializing to a random permutation.
size | Optional size of the permutation |
rng | Random number generator. |
|
inline |
Copy constructor
other | Another permutation |
|
inlinevirtual |
Destructor
|
inlineprotected |
Sets a specific value without checking validity.
index | Index of the entry |
value | New value |
|
inline |
The image of a specific integer in range 0 .. size-1.
index | Given integer |
|
inlineprotected |
|
inline |
Grows the permutation by a given number of elements.
by | Number of elements to increase the size by |
|
inline |
The image of a specific integer in range 0 .. size-1.
index | Given integer |
|
inline |
Calculates the product of this and another permutation. The result is equivalent to applying the second permutation first and this one afterwards.
rhs | Right hand side permutation |
|
inline |
Assignment operator.
other | Another permutation |
|
inline |
Resets the permutation to identity.
|
inline |
Resizes the permutation and resets it to identity.
new_size | New size |
|
inline |
Resizes the permutation, retaining the contents. This may fail if it cannot be shrunken this way and will throw a permutation_shrink_exception in that case.
new_size | New size of the permutation |
|
inline |
|
inline |
Makes this permutation its own inverse.
Create a temporary copy
|
inline |
Swaps the preimages of two integers in range 0 .. size-1.
a | First integer |
b | Second integer |
|
inline |
Shrinks the permutation by a given number of elements.
by | Number of elements to decrease the size by |
|
inline |
Shuffles a permutation.
rng | Random number generator. |
|
inline |
|
inline |
Swaps the images of two integers in range 0 .. size-1.
a | First integer |
b | Second integer |
|
friend |
Class to enumerate permutations.
|
friend |
Class to setup a permutation which can be put before a vector.
Arranges part of a given permutation such that it can be used to view a vector in a sorted way.
permutation | The given permutation to be changed |
first | First index of the part |
beyond | Beyond index of the part |
less | Functor to compare two elements |
|
protected |