Template Function brille::apply_inverse_permutation

Function Documentation

template<typename ObjItr, typename PermItr>
void brille::apply_inverse_permutation(ObjItr objects, ObjItr end, PermItr indices)

Apply an inverse permutation to a random access iterable object.

For an inverse permutation held in one random access iterable object of length N comprised of the integers (0,N] in some order, and a second iterable containing N objects, find the inverse permuted iterable such that

permuted_object_iterable[index_iterable[i]] = object_iterable[i]

for all i by swapping elements in place and using the inverse permutation iterable as a scratch workspace.

Parameters
  • objects: An iterator pointing to the first element of the object iterable

  • end: An iterator pointing to the end of the object iterable

  • indices: An iterator pointing to the first element of the inverse permutation iterable