c++ - Shifting elements in array by N elements -
I have an array where each 'element' is made up of 4 consecutive values. After the update, I take the array to the end of the 4 values and at the beginning I put 4 new values.
Shift:
int m = 4; For (int i = _vsize - 1; i + 1 - m! = 0; i -) {_varray [i] = std :: move (_varray [i - m]) for; }
Insertion:
memcpy (& amp; _varray [0], glm :: value_ptr (new_element), 4 * size (float));
Where new_element
is of type glm :: vec4
which contains 4 new values.
Any suggestions on how to improve it?
(I'm just transferring from one element, but to say the flexibility to be able to loop is to say 8 times, without putting any loop in it)
Thank you. / P>
You can try to copy a range of values from another category into the same container Since limitations are and you are copying right you can not use the regular std :: copy
but instead of std :: copy_backward
Should use.
int m = 4; // It is a respected std :: copy_backward (& amp; _varray [0], & _varray [_vsize -m] & amp; _varray [_vsize]) of its 'element' size;
There too, but this is really nothing because your float
values are not running.
Comments
Post a Comment