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

Method iaddReturnMinimized

arraycontainer.go:290–314  ·  view source on GitHub ↗
(x uint16)

Source from the content-addressed store, hash-verified

288}
289
290func (ac *arrayContainer) iaddReturnMinimized(x uint16) container {
291 // Special case adding to the end of the container.
292 l := len(ac.content)
293 if l > 0 && l < arrayDefaultMaxSize && ac.content[l-1] < x {
294 ac.content = append(ac.content, x)
295 return ac
296 }
297
298 loc := binarySearch(ac.content, x)
299
300 if loc < 0 {
301 if len(ac.content) >= arrayDefaultMaxSize {
302 a := ac.toBitmapContainer()
303 a.iadd(x)
304 return a
305 }
306 s := ac.content
307 i := -loc - 1
308 s = append(s, 0)
309 copy(s[i+1:], s[i:])
310 s[i] = x
311 ac.content = s
312 }
313 return ac
314}
315
316// iremoveReturnMinimized is allowed to change the return type to minimize storage.
317func (ac *arrayContainer) iremoveReturnMinimized(x uint16) container {

Callers

nothing calls this directly

Calls 3

toBitmapContainerMethod · 0.95
binarySearchFunction · 0.85
iaddMethod · 0.65

Tested by

no test coverage detected