-
-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Will Fitzgerald
committed
Aug 28, 2017
1 parent
988f4f2
commit 30284c1
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// +build go1.9 | ||
|
||
package bitset | ||
|
||
import "math/bits" | ||
|
||
func popcntSlice(s []uint64) uint64 { | ||
var cnt int | ||
for _, x := range s { | ||
cnt += bits.OnesCount64(x) | ||
} | ||
return uint64(cnt) | ||
} | ||
|
||
func popcntMaskSlice(s, m []uint64) uint64 { | ||
var cnt int | ||
for i := range s { | ||
cnt += bits.OnesCount64(s[i] &^ m[i]) | ||
} | ||
return uint64(cnt) | ||
} | ||
|
||
func popcntAndSlice(s, m []uint64) uint64 { | ||
var cnt int | ||
for i := range s { | ||
cnt += bits.OnesCount64(s[i] & m[i]) | ||
} | ||
return uint64(cnt) | ||
} | ||
|
||
func popcntOrSlice(s, m []uint64) uint64 { | ||
var cnt int | ||
for i := range s { | ||
cnt += bits.OnesCount64(s[i] | m[i]) | ||
} | ||
return uint64(cnt) | ||
} | ||
|
||
func popcntXorSlice(s, m []uint64) uint64 { | ||
var cnt int | ||
for i := range s { | ||
cnt += bits.OnesCount64(s[i] ^ m[i]) | ||
} | ||
return uint64(cnt) | ||
} |
File renamed without changes.