I would propose a different approach that is very efficient if the distribution is narrow (we have many ripetitions)
Try this (there are many (10000000 x 17)):
for (int i=0; i<sizeof(array)/sizeof(DWORD); i++)
if (i%2) array[i] = 17; else array[i] = i;
Yes, but this is not a narrow distribution anyway, you have 10M values equal and 10M values different...
To speed up the calculation you
have to sort the array, one of the fastest ways (if you don't hate the math) is to sample at powers of 2 steps as described
here...
P.S. if the time is relevant, and in your case with so large arrays of data it
is the case, the suggestion from JJ to use assembler is appropriate.
EDIT: if you reduce to 20K different values it takes 350ms on my machine:
for (int i=0; i<sizeof(array)/sizeof(DWORD); i++)
if (i%1000) array[i] = 17; else array[i] = i;