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

Method numberOfRuns

bitmapcontainer.go:1251–1272  ·  view source on GitHub ↗

reference the java implementation https://github.com/RoaringBitmap/RoaringBitmap/blob/master/src/main/java/org/roaringbitmap/BitmapContainer.java#L875-L892

()

Source from the content-addressed store, hash-verified

1249// reference the java implementation
1250// https://github.com/RoaringBitmap/RoaringBitmap/blob/master/src/main/java/org/roaringbitmap/BitmapContainer.java#L875-L892
1251func (bc *bitmapContainer) numberOfRuns() int {
1252 if bc.cardinality == 0 {
1253 return 0
1254 }
1255
1256 var numRuns uint64
1257 nextWord := bc.bitmap[0]
1258
1259 for i := 0; i < len(bc.bitmap)-1; i++ {
1260 word := nextWord
1261 nextWord = bc.bitmap[i+1]
1262 numRuns += popcount((^word)&(word<<1)) + ((word >> 63) &^ nextWord)
1263 }
1264
1265 word := nextWord
1266 numRuns += popcount((^word) & (word << 1))
1267 if (word & 0x8000000000000000) != 0 {
1268 numRuns++
1269 }
1270
1271 return int(numRuns)
1272}
1273
1274// convert to run or array *if needed*
1275func (bc *bitmapContainer) toEfficientContainer() container {

Callers 1

toEfficientContainerMethod · 0.95

Calls 1

popcountFunction · 0.70

Tested by

no test coverage detected