I have a vector X
of u32
that I need to access the elements of in a known order. There's another vector orderings
containing a list of usize
which is the order I need to access the elements of X in.
At the moment I'm doing:
for order in orderings.iter() {
let val = X[*order];
//do stuff with val
}
Unfortunately this is pretty slow as I'm having to index into X every single iteration of the loop, is there a way I can just get the val
for each loop directly without having to do this indexing that is faster?