Function gut::utils::slice::apply_permutation[][src]

pub fn apply_permutation<A>(permutation: &[usize], array: &mut A) where
    A: Swap + ?Sized
Expand description

Apply a given permutation of indices to the given array of values in place.

Example

use meshx::utils::slice::apply_permutation;
let perm = vec![7, 8, 2, 3, 4, 1, 6, 5, 0];
let mut values = String::from("tightsemi");
// SAFETY: we are just permuting ASCII chars here for demonstrative purposes.
apply_permutation(&perm, unsafe { values.as_bytes_mut() });
assert_eq!(values, "mightiest");