You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
410 B

  1. // +build !go1.9
  2. package bitset
  3. var deBruijn = [...]byte{
  4. 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4,
  5. 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5,
  6. 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11,
  7. 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6,
  8. }
  9. func trailingZeroes64(v uint64) uint {
  10. return uint(deBruijn[((v&-v)*0x03f79d71b4ca8b09)>>58])
  11. }