refactor-for-testability (#3)
Co-authored-by: jdl <jdl@desktop> Co-authored-by: jdl <jdl@crumpington.com> Reviewed-on: #3
This commit is contained in:
21
peer/bitset.go
Normal file
21
peer/bitset.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package peer
|
||||
|
||||
const bitSetSize = 512 // Multiple of 64.
|
||||
|
||||
type bitSet [bitSetSize / 64]uint64
|
||||
|
||||
func (bs *bitSet) Set(i int) {
|
||||
bs[i/64] |= 1 << (i % 64)
|
||||
}
|
||||
|
||||
func (bs *bitSet) Clear(i int) {
|
||||
bs[i/64] &= ^(1 << (i % 64))
|
||||
}
|
||||
|
||||
func (bs *bitSet) ClearAll() {
|
||||
clear(bs[:])
|
||||
}
|
||||
|
||||
func (bs *bitSet) Get(i int) bool {
|
||||
return bs[i/64]&(1<<(i%64)) != 0
|
||||
}
|
||||
Reference in New Issue
Block a user