Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Look at <a href="http://graphics.stanford.edu/~seander/bithacks.html" rel="nofollow">Bit Twiddling Hacks</a></p> <ul> <li>Counting bits set <ul> <li><a href="http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetNaive" rel="nofollow">Counting bits set, naive way</a></li> <li><a href="http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetTable" rel="nofollow">Counting bits set by lookup table</a></li> <li><a href="http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan" rel="nofollow">Counting bits set, Brian Kernighan's way</a></li> <li><a href="http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSet64" rel="nofollow">Counting bits set in 12, 24, or 32-bit words using 64-bit instructions</a></li> <li><a href="http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel" rel="nofollow">Counting bits set, in parallel</a></li> <li><a href="http://graphics.stanford.edu/~seander/bithacks.html#CountBitsFromMSBToPos" rel="nofollow">Count bits set (rank) from the most-significant bit upto a given position</a></li> <li><a href="http://graphics.stanford.edu/~seander/bithacks.html#SelectPosFromMSBRank" rel="nofollow">Select the bit position (from the most-significant bit) with the given count (rank)</a></li> </ul></li> </ul> <p><strong>Edit</strong> As for the 'bit position bucket accumulation' (<code>bit_counter[]</code>) I have a feeling that this might be a good case for valarrays + masking. That'd be a fair bit of coding+testing+profiling though. Let me know if you are really interested. </p> <p>You could, these days, come very close to valarray behaviour using <em>tied tuples</em> (TR1, boost or C++11); I have a feeling it would come out being simpler to read and slower to compile.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload