Guest User

in-place interleave and memmove

a guest
Feb 8th, 2011
136
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void deinterleave_mm(int *a, int len)
  2. {
  3.     for (int i = 1; i < len/2; i++)
  4.     {
  5.         // move a left int into place
  6.         int t = a[i*2];
  7.         memmove(&a[i+1], &a[i], i * sizeof(int));
  8.         a[i] = t;
  9.     }
  10. }
  11.  
  12. void interleave_mm(int *a, int len)
  13. {
  14.     for (int i = len/2-1; i > 0; i--)
  15.     {
  16.         // move a left int into place
  17.         int t = a[i];
  18.         memmove(&a[i], &a[i+1], i * sizeof(int));
  19.         a[i*2] = t;
  20.     }
  21. }
RAW Paste Data