OK, it may sound a bit complicated, but this is what I\'m trying to do :
10101010101
{ 0, 2, 4, 6, 8, 10 }
The fastest I can think of right now would be using a pre-generated array of all numbers (it doesn't have to be all numbers, you can for example break the numbers in 8-bit or 16-bit parts and then concatenate the returned arrays with some proper additions to account for the actual position of the bits).map