MCPcopy Index your code
hub / github.com/RoaringBitmap/roaring / NextUnsetBit

Method NextUnsetBit

bitmapcontainer.go:1186–1207  ·  view source on GitHub ↗
(i uint)

Source from the content-addressed store, hash-verified

1184}
1185
1186func (bc *bitmapContainer) NextUnsetBit(i uint) int {
1187 var (
1188 x = i / 64
1189 length = uint(len(bc.bitmap))
1190 )
1191 if x >= length {
1192 return int(i)
1193 }
1194 w := bc.bitmap[x]
1195 w = w >> (i % 64)
1196 w = ^w
1197 if w != 0 {
1198 return int(i) + countTrailingZeros(w)
1199 }
1200 x++
1201 for ; x < length; x++ {
1202 if bc.bitmap[x] != 0xFFFFFFFFFFFFFFFF {
1203 return int(x*64) + countTrailingZeros(^bc.bitmap[x])
1204 }
1205 }
1206 return int(length * 64)
1207}
1208
1209// PrevSetBit returns the previous set bit e.g the previous int packed into the bitmaparray
1210func (bc *bitmapContainer) PrevSetBit(i int) int {

Callers 3

nextMethod · 0.80
advanceIfNeededMethod · 0.80

Calls 1

countTrailingZerosFunction · 0.70

Tested by

no test coverage detected