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

Method addwithptr

roaring.go:1171–1185  ·  view source on GitHub ↗

add the integer x to the bitmap, return the container and its index

(x uint32)

Source from the content-addressed store, hash-verified

1169
1170// add the integer x to the bitmap, return the container and its index
1171func (rb *Bitmap) addwithptr(x uint32) (int, container) {
1172 hb := highbits(x)
1173 ra := &rb.highlowcontainer
1174 i := ra.getIndex(hb)
1175 var c container
1176 if i >= 0 {
1177 c = ra.getWritableContainerAtIndex(i).iaddReturnMinimized(lowbits(x))
1178 rb.highlowcontainer.setContainerAtIndex(i, c)
1179 return i, c
1180 }
1181 newac := newArrayContainer()
1182 c = newac.iaddReturnMinimized(lowbits(x))
1183 rb.highlowcontainer.insertNewKeyValueAt(-i-1, hb, c)
1184 return -i - 1, c
1185}
1186
1187// CheckedAdd adds the integer x to the bitmap and return true if it was added (false if the integer was already present)
1188func (rb *Bitmap) CheckedAdd(x uint32) bool {

Callers 1

AddManyMethod · 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

no test coverage detected