Constexpr-compatible container-abstracted permutation. More...
#include <Permutations.h>
Public Types | |
using | T = std::decay_t< decltype(std::declval< Container >().at(0))> |
Public Member Functions | |
constexpr | Permutation (unsigned N) |
Construct the identity permutation of size N. | |
constexpr | Permutation (Container p) |
Construct a permutation from data. | |
constexpr | Permutation (const unsigned N, unsigned i) |
Construct the i-th permutation of size N. | |
constexpr bool | next () |
constexpr bool | prev () |
constexpr std::size_t | index () const |
constexpr Permutation | inverse () const |
constexpr auto | at (const std::size_t i) const -> decltype(auto) |
constexpr auto | operator() (const std::size_t i) const -> decltype(auto) |
template<typename OtherContainer > | |
constexpr OtherContainer | apply (const OtherContainer &other) const |
constexpr Permutation | compose (const Permutation &other) const |
Compose two permutations. More... | |
Static Public Member Functions | |
template<typename OtherContainer > | |
static constexpr Permutation | ordering (const OtherContainer &unordered) |
Discover on ordering permutation of an unordered container. | |
Data Fields | |
Container | sigma |
The permutation in 'one-line' representation. | |
Constexpr-compatible container-abstracted permutation.
Permutations contain only non-negative integers, with each number up less than its length used once. This class can be used only to represent permutations of sequences of a set of items, not of a multiset (with repeated elements).
Container | implementing begin/end, at and size methods. If these methods of the container are constexpr, then this class is constexpr. |
The permutation itself represented in one-line 'notation'. E.g. a vector containing the indices 0, 3, 2, 1 represents the permutation with p(0) = 0, p(1) = 3, p(2) = 2 and p(3) = 1.
|
inline |
Compose two permutations.
The resulting permutation of this composition applies other
first, then this
.