7 #ifndef INCLUDE_MOLASSEMBLER_TEMPLE_STRONG_INDEX_PERMUTATION_H
8 #define INCLUDE_MOLASSEMBLER_TEMPLE_STRONG_INDEX_PERMUTATION_H
13 namespace Molassembler {
16 template<
typename Key,
typename Value>
21 using value_type = Value;
24 using base_iterator = std::vector<unsigned>::const_iterator;
25 using iterator_category = base_iterator::iterator_category;
26 using value_type = std::pair<Key, Value>;
28 Iterator(base_iterator a, base_iterator b) : begin(std::move(a)), iter(std::move(b)) {}
30 value_type operator * ()
const {
32 Key {
static_cast<typename Key::value_type
>(iter - begin)},
49 return std::tie(iter);
68 template<typename T, std::enable_if_t<std::is_convertible<T, unsigned>::value,
int>* =
nullptr>
69 explicit StrongIndexPermutation(std::initializer_list<T> vs) : permutation(std::move(vs)) {}
74 template<
typename Container>
75 static std::enable_if_t<!std::is_same<Container, Permutation::Sigma>::value, StrongIndexPermutation> from(
const Container& p) {
77 std::is_convertible<Traits::getValueType<Container>,
unsigned>::value,
78 "Value type of container must be convertible to unsigned!"
80 Permutation::Sigma sigma;
82 sigma.emplace_back(
static_cast<unsigned>(v));
84 return StrongIndexPermutation {
Permutation {std::move(sigma)}};
90 Value at(
const Key i)
const {
91 return Value {permutation.at(i)};
94 Value operator() (
const Key i)
const {
95 return Value {permutation.at(i)};
98 Key indexOf(
const Value v)
const {
99 return Key {permutation.indexOf(v)};
102 unsigned size()
const {
103 return permutation.size();
106 StrongIndexPermutation<Value, Key> inverse()
const {
107 return StrongIndexPermutation<Value, Key> {permutation.inverse()};
110 template<
typename OtherValue>
111 StrongIndexPermutation<Key, OtherValue>
112 compose(
const StrongIndexPermutation<Value, OtherValue>& other)
const {
113 return StrongIndexPermutation<Key, OtherValue> {permutation.
compose(other.permutation)};
116 StrongIndexPermutation compose(
const StrongIndexPermutation<Value, Value>& other)
const {
117 return StrongIndexPermutation {permutation.
compose(other.permutation)};
121 return std::tie(permutation);
134 Iterator begin()
const {
136 std::begin(permutation.
sigma),
137 std::begin(permutation.
sigma)
141 Iterator end()
const {
143 std::begin(permutation.
sigma),
144 std::end(permutation.
sigma)
Provides functionality related to permutations.
std::vector< Vertex > Permutation
Representation of a shape vertex permutation.
Definition: Data.h:36
Generates all operators using a method returning a tuple.
Definition: OperatorSuppliers.h:78
Container-abstracted permutation.
Definition: Permutations.h:287
Sigma sigma
The permutation in 'one-line' representation.
Definition: Permutations.h:460
Permutation compose(const Permutation &other) const
Compose two permutations.
Definition: Permutations.h:448
Definition: StrongIndexPermutation.h:23
Definition: StrongIndexPermutation.h:17