Closed Tony-Kwan closed 3 years ago
Yes. It should look something like this...
func flipBitmapRange(bitmap []uint64, start int, end int) {
if start >= end {
return
}
firstword := start / 64
endword := (end - 1) / 64
bitmap[firstword] ^= ^(^uint64(0) << uint(start%64))
for i := firstword; i < endword; i++ {
bitmap[i] = ^bitmap[i]
}
bitmap[endword] ^= ^uint64(0) >> (uint(-end) % 64)
}
Do you want to write a pull request ?
Thx. I will write a pr.
Fixed. Closing.
Can offer a range Flip method? Flip(start, end uint) flip bit in [start, end)