MCPcopy Create free account
hub / github.com/RoaringBitmap/roaring / CheckedAdd

Method CheckedAdd

roaring64/roaring64.go:336–347  ·  view source on GitHub ↗

CheckedAdd adds the integer x to the bitmap and return true if it was added (false if the integer was already present)

(x uint64)

Source from the content-addressed store, hash-verified

334
335// CheckedAdd adds the integer x to the bitmap and return true if it was added (false if the integer was already present)
336func (rb *Bitmap) CheckedAdd(x uint64) bool {
337 hb := highbits(x)
338 i := rb.highlowcontainer.getIndex(hb)
339 if i >= 0 {
340 c := rb.highlowcontainer.getWritableContainerAtIndex(i)
341 return c.CheckedAdd(lowbits(x))
342 }
343 newBitmap := roaring.NewBitmap()
344 newBitmap.Add(lowbits(x))
345 rb.highlowcontainer.insertNewKeyValueAt(-i-1, hb, newBitmap)
346 return true
347}
348
349// AddInt adds the integer x to the bitmap (convenience method: the parameter is casted to uint64 and we call Add)
350func (rb *Bitmap) AddInt(x int) {

Callers 1

TestAddCheckedRemove64Function · 0.45

Calls 6

AddMethod · 0.95
highbitsFunction · 0.70
lowbitsFunction · 0.70
getIndexMethod · 0.45
insertNewKeyValueAtMethod · 0.45

Tested by 1

TestAddCheckedRemove64Function · 0.36