40#ifndef GEOGRAM_BASIC_PERMUTATION
41#define GEOGRAM_BASIC_PERMUTATION
57 namespace Permutation {
81 std::vector<bool> visited(permutation.
size(),
false);
83 if(permutation[i] >= permutation.
size()) {
86 if(visited[permutation[i]]) {
89 visited[permutation[i]] =
true;
131 permutation[i] &= ~MARKED_BIT;
174 mark(permutation, k);
177 pdata + i * elemsize, pdata + j * elemsize, elemsize
180 mark(permutation, j);
227 mark(permutation, k);
231 mark(permutation, j);
267 mark(permutation, j);
272 mark(permutation, j);
294 invert[permutation[i]] = i;
#define geo_debug_assert(x)
Verifies that a condition is met.
Vector with aligned memory allocation.
index_t size() const
Gets the number of elements.
Common include file, providing basic definitions. Should be included before anything else by all head...
Types and functions for memory manipulation.
unsigned char byte
Unsigned byte type.
byte * pointer
Pointer to unsigned byte(s)
void copy(void *to, const void *from, size_t size)
Copies a memory block.
bool is_marked(const vector< index_t > &permutation, index_t i)
Checks if a permutation element has been visited.
constexpr index_t MAX_SIZE
Maximum size of a permutation that can be applied in-place.
void unmark(vector< index_t > &permutation, index_t i)
Unmarks a permutation element.
void mark(vector< index_t > &permutation, index_t i)
Marks a permutation element as visited.
constexpr index_t MARKED_BIT
Mark used to mark elements for in-place permutation.
void invert(vector< index_t > &permutation)
Inverts a permutation in-place.
bool is_valid(const vector< index_t > &permutation)
Checks whether a vector is a valid permutation.
void apply(void *data, const vector< index_t > &permutation_in, size_t elemsize)
Applies a permutation in-place. Permutes the first N elements of size elemsize in array data using pe...
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.
Types and functions for numbers manipulation.