Source File
popcnt_19.go
Belonging Package
github.com/bits-and-blooms/bitset
//go:build go1.9// +build go1.9package bitsetimportfunc popcntSlice( []uint64) uint64 {var intfor , := range {+= bits.OnesCount64()}return uint64()}func popcntMaskSlice(, []uint64) uint64 {var int// this explicit check eliminates a bounds check in the loopif len() < len() {panic("mask slice is too short")}for := range {+= bits.OnesCount64([] &^ [])}return uint64()}func popcntAndSlice(, []uint64) uint64 {var int// this explicit check eliminates a bounds check in the loopif len() < len() {panic("mask slice is too short")}for := range {+= bits.OnesCount64([] & [])}return uint64()}func popcntOrSlice(, []uint64) uint64 {var int// this explicit check eliminates a bounds check in the loopif len() < len() {panic("mask slice is too short")}for := range {+= bits.OnesCount64([] | [])}return uint64()}func popcntXorSlice(, []uint64) uint64 {var int// this explicit check eliminates a bounds check in the loopif len() < len() {panic("mask slice is too short")}for := range {+= bits.OnesCount64([] ^ [])}return uint64()}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |