MCPcopy
hub / github.com/RoaringBitmap/roaring / CheckedRemove

Method CheckedRemove

roaring.go:1223–1239  ·  view source on GitHub ↗

CheckedRemove removes the integer x from the bitmap and return true if the integer was effectively removed (and false if the integer was not present)

(x uint32)

Source from the content-addressed store, hash-verified

1221
1222// CheckedRemove removes the integer x from the bitmap and return true if the integer was effectively removed (and false if the integer was not present)
1223func (rb *Bitmap) CheckedRemove(x uint32) bool {
1224 // TODO: add unit tests for this method
1225 hb := highbits(x)
1226 i := rb.highlowcontainer.getIndex(hb)
1227 if i >= 0 {
1228 C := rb.highlowcontainer.getWritableContainerAtIndex(i)
1229 oldcard := C.getCardinality()
1230 C = C.iremoveReturnMinimized(lowbits(x))
1231 rb.highlowcontainer.setContainerAtIndex(i, C)
1232 if rb.highlowcontainer.getContainerAtIndex(i).isEmpty() {
1233 rb.highlowcontainer.removeAtIndex(i)
1234 return true
1235 }
1236 return C.getCardinality() < oldcard
1237 }
1238 return false
1239}
1240
1241// IsEmpty returns true if the Bitmap is empty (it is faster than doing (GetCardinality() == 0))
1242func (rb *Bitmap) IsEmpty() bool {

Callers

nothing calls this directly

Calls 10

highbitsFunction · 0.70
lowbitsFunction · 0.70
getCardinalityMethod · 0.65
isEmptyMethod · 0.65
getIndexMethod · 0.45
setContainerAtIndexMethod · 0.45
getContainerAtIndexMethod · 0.45
removeAtIndexMethod · 0.45

Tested by

no test coverage detected