Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

popcnt_compat.go 514B

1234567891011121314151617
  1. // +build !go1.9
  2. package roaring
  3. // bit population count, take from
  4. // https://code.google.com/p/go/issues/detail?id=4988#c11
  5. // credit: https://code.google.com/u/arnehormann/
  6. // credit: https://play.golang.org/p/U7SogJ7psJ
  7. // credit: http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
  8. func popcount(x uint64) uint64 {
  9. x -= (x >> 1) & 0x5555555555555555
  10. x = (x>>2)&0x3333333333333333 + x&0x3333333333333333
  11. x += x >> 4
  12. x &= 0x0f0f0f0f0f0f0f0f
  13. x *= 0x0101010101010101
  14. return x >> 56
  15. }