Moby
permute.h
1 #ifndef _MOBY_PERMUTE_
2 #define _MOBY_PERMUTE_
3 
4 #include <iterator>
5 
19 namespace Moby {
20 
27 template <class ForwardIterator, class RandomAccessIterator1, class RandomAccessIterator2>
28 void permute(ForwardIterator mapping_begin, ForwardIterator mapping_end, RandomAccessIterator1 input_begin, RandomAccessIterator2 output_begin)
29 {
30  // setup the target index
31  unsigned target_index = 0;
32 
33  for (ForwardIterator i = mapping_begin; i != mapping_end; i++)
34  output_begin[target_index++] = input_begin[*i];
35 }
36 
37 } // end namespace
38 
39 #endif
40 
void permute(ForwardIterator mapping_begin, ForwardIterator mapping_end, RandomAccessIterator1 input_begin, RandomAccessIterator2 output_begin)
Definition: permute.h:28