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

Method Add

roaring.go:1156–1168  ·  view source on GitHub ↗

Add the integer x to the bitmap

(x uint32)

Source from the content-addressed store, hash-verified

1154
1155// Add the integer x to the bitmap
1156func (rb *Bitmap) Add(x uint32) {
1157 hb := highbits(x)
1158 ra := &rb.highlowcontainer
1159 i := ra.getIndex(hb)
1160 if i >= 0 {
1161 var c container
1162 c = ra.getWritableContainerAtIndex(i).iaddReturnMinimized(lowbits(x))
1163 rb.highlowcontainer.setContainerAtIndex(i, c)
1164 } else {
1165 newac := newArrayContainer()
1166 rb.highlowcontainer.insertNewKeyValueAt(-i-1, hb, newac.iaddReturnMinimized(lowbits(x)))
1167 }
1168}
1169
1170// add the integer x to the bitmap, return the container and its index
1171func (rb *Bitmap) addwithptr(x uint32) (int, container) {

Callers 15

AddIntMethod · 0.95
TestIssue386Function · 0.95
TestCloneOfCOWFunction · 0.95
TestStringerCOWFunction · 0.95
TestFastCardCOWFunction · 0.95
TestIntersects1COWFunction · 0.95
TestRangePanicCOWFunction · 0.95
TestRangeRemovalCOWFunction · 0.95
TestBitmapRankCOWFunction · 0.95
TestBitmapSelectCOWFunction · 0.95

Calls 8

newArrayContainerFunction · 0.85
highbitsFunction · 0.70
lowbitsFunction · 0.70
iaddReturnMinimizedMethod · 0.65
getIndexMethod · 0.45
setContainerAtIndexMethod · 0.45
insertNewKeyValueAtMethod · 0.45

Tested by 15

TestIssue386Function · 0.76
TestCloneOfCOWFunction · 0.76
TestStringerCOWFunction · 0.76
TestFastCardCOWFunction · 0.76
TestIntersects1COWFunction · 0.76
TestRangePanicCOWFunction · 0.76
TestRangeRemovalCOWFunction · 0.76
TestBitmapRankCOWFunction · 0.76
TestBitmapSelectCOWFunction · 0.76
TestBitmapExtraCOWFunction · 0.76