This website works better with JavaScript.
Home
Issues
Pull Requests
Milestones
AI流水线
Repositories
Datasets
论坛
实训
竞赛
大数据
AI开发
Register
Sign In
JointCloud
/
common
Not watched
Unwatch
Watch all
Watch but not notify
1
Star
0
Fork
0
Code
Releases
0
Wiki
evaluate
Activity
Issues
0
Pull Requests
0
Datasets
Model
Cloudbrain
HPC
Browse Source
增加Bitmap类型
pull/38/head
Sydonian
1 year ago
parent
c8d56f9697
commit
e0d5306ba5
1 changed files
with
29 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+29
-0
pkgs/bitmap/bitmap.go
+ 29
- 0
pkgs/bitmap/bitmap.go
View File
@@ -0,0 +1,29 @@
package bitmap
type Bitmap64 uint64
func (b *Bitmap64) Set(index int, val bool) {
if val {
*b |= 1 << index
} else {
*b &= ^(1 << index)
}
}
func (b *Bitmap64) Get(index int) bool {
return (*b & (1 << index)) > 0
}
func (b *Bitmap64) Or(other *Bitmap64) {
*b |= *other
}
func (b *Bitmap64) Weight() int {
v := *b
cnt := 0
for v > 0 {
cnt++
v &= (v - 1)
}
return cnt
}
Write
Preview
Loading…
Cancel
Save