Moving arrays with a c library
i'm writing small library that moves elements inside overlapping arrays and for efficiency's sake, it is important if it is being moved from left to right or right to left. this may seem like a basic question, but please hear me out....
if it is being compiled with the option of a loop doing it:
left to right:
for ( i = 0; i < n; )
dest[i] = src[i];
will not suffice, as the highest members of src MIGHT get overwritten by the TO-BE lower members of dest, so it has to be done this:
for ( i = n; i--; )
dest[i] = src[i];
same could be said if you're doing a right to left move:
for ( i = n; i--; )
dest[i] = src[i];
won't do so:
for ( i = 0; i < n; )
dest[i] = src[i];
THIS IS THE QUESTION:
now, this is all well and settled, but i want to include the option of it being compiled with optimized moving instructions such as those found in SSE, possibly made available by libraries, such as, the string.h library. i've looked through it and other libraries out there, but i can't find one that explicitly does the moving/copying in a right-to-left or left-to-right fashion.