github.com/coyove/sdss@v0.0.0-20231129015646-c2ec58cca6a2/contrib/roaring/popcnt_slices.go (about) 1 package roaring 2 3 func popcntSliceGo(s []uint64) uint64 { 4 cnt := uint64(0) 5 for _, x := range s { 6 cnt += popcount(x) 7 } 8 return cnt 9 } 10 11 func popcntMaskSliceGo(s, m []uint64) uint64 { 12 cnt := uint64(0) 13 for i := range s { 14 cnt += popcount(s[i] &^ m[i]) 15 } 16 return cnt 17 } 18 19 func popcntAndSliceGo(s, m []uint64) uint64 { 20 cnt := uint64(0) 21 for i := range s { 22 cnt += popcount(s[i] & m[i]) 23 } 24 return cnt 25 } 26 27 func popcntOrSliceGo(s, m []uint64) uint64 { 28 cnt := uint64(0) 29 for i := range s { 30 cnt += popcount(s[i] | m[i]) 31 } 32 return cnt 33 } 34 35 func popcntXorSliceGo(s, m []uint64) uint64 { 36 cnt := uint64(0) 37 for i := range s { 38 cnt += popcount(s[i] ^ m[i]) 39 } 40 return cnt 41 }