efficient way to copy array with mask in c++ -


i have 2 arrays. 1 "x" factor size of second one.

i need copy first (bigger) array second (smaller) array x element. meaning 0,x,2x.

each array sits block in memory. array of simple values. doing using loop.

is there faster smarter way this?

maybe ostream? thanks!

you doing right?

#include <cstddef>  int main() {   const std::size_t n = 20;   const std::size_t x = 5;   int input[n*x];   int output[n];    for(std::size_t = 0; < n; ++i)     output[i] = input[i*x]; } 

well, don't know function can that, use loop. fast.

edit: faster solution (to avoid multiplications)(c++03 version)

int* inputit = input; int* outputit = output; int* outputend = output+n;  while(outputit != outputend) {   *outputit = *inputit;    ++outputit;    inputit+=x; } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -