11#ifndef PERMUTAHEDRAL_REPRESENTATION_PERMUTATION_ITERATOR_H_
12#define PERMUTAHEDRAL_REPRESENTATION_PERMUTATION_ITERATOR_H_
17#include <boost/range/iterator_range.hpp>
21namespace coxeter_triangulation {
29 :
public boost::iterator_facade<Permutation_iterator, std::vector<uint> const, boost::forward_traversal_tag> {
30 using value_t = std::vector<uint>;
33 friend class boost::iterator_core_access;
37 value_t
const& dereference()
const {
return value_; }
39 void swap_two_indices(std::size_t i, std::size_t j) {
41 value_[i] = value_[j];
45 void elementary_increment() {
47 while (d_[j] == j + 1) {
56 uint x = (k % 2 ? d_[j] : 0);
57 swap_two_indices(k, x);
61 void elementary_increment_optim_3() {
64 swap_two_indices(1 + (ct_ % 2), 0);
68 while (d_[j] == j + 1) {
77 uint x = (k % 2 ? d_[j] : 0);
78 swap_two_indices(k, x);
85 elementary_increment_optim_3();
87 elementary_increment();
91 Permutation_iterator(
const uint& n) : value_(n), is_end_(n == 0), optim_3_(n >= 3), n_(n), d_(n), ct_(5) {
92 for (uint i = 0; i < n; ++i) {
96 if (n > 0) d_[n - 1] = -1;
102 void reinitialize() {
103 if (n_ > 0) is_end_ =
false;
112 std::vector<uint> d_;
Class that allows the user to generate permutations. Based on the optimization of the Heap's algorith...
Definition: Permutation_iterator.h:29
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14