40#ifndef GEOGRAM_BASIC_PERMUTATION
41#define GEOGRAM_BASIC_PERMUTATION
57 namespace Permutation {
71 std::vector<bool> visited(permutation.
size(),
false);
73 if(permutation[i] >= permutation.
size()) {
76 if(visited[permutation[i]]) {
79 visited[permutation[i]] =
true;
173 mark(permutation, k);
176 pdata + i * elemsize, pdata + j * elemsize, elemsize
179 mark(permutation, j);
225 mark(permutation, k);
229 mark(permutation, j);
264 mark(permutation, j);
269 mark(permutation, j);
291 invert[permutation[i]] = i;
#define geo_debug_assert(x)
Verifies that a condition is met.
Common include file, providing basic definitions. Should be included before anything else by all head...
Vector with aligned memory allocation.
index_t size() const
Gets the number of elements.
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.
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.
void invert(vector< index_t > &permutation)
Inverts a permutation in-place.
void apply(void *data, const vector< index_t > &permutation_in, index_t elemsize)
Applies a permutation in-place. Permutes the first N elements of size elemsize in array data using pe...
bool is_valid(const vector< index_t > &permutation)
Checks whether a vector is a valid permutation.
Global Vorpaline namespace.
geo_signed_index_t signed_index_t
The type for storing and manipulating indices differences.
geo_index_t index_t
The type for storing and manipulating indices.
Types and functions for numbers manipulation.