Applying a permutation to a vector, part 1--Raymond Chen

It seems a simple problem, yet...

Applying a permutation to a vector, part 1

by Raymond Chen

From the article:

Suppose you have a vector indices of N integers that is a permutation of the numbers 0 through N − 1. Suppose you also have a vector v of N objects. The mission is to apply the permutation to the vector. If we let v2 represent the contents of the vector at the end of the operation, the requirement is that v2[i] = v[indices[i]] for all i...

Add a Comment

Comments are closed.

Comments (1)

0 0

squelart said on Jan 3, 2017 03:19 PM:

Part 2: [url="https://blogs.msdn.microsoft.com/oldnewthing/20170103-00/?p=95105"]https://blogs.msdn.microsoft.com/oldnewthing/20170103-00/?p=95105[/url]