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

Method getIndex

roaringarray.go:358–366  ·  view source on GitHub ↗

getIndex returns the index of the container with key `x` if no such container exists a negative value is returned

(x uint16)

Source from the content-addressed store, hash-verified

356// getIndex returns the index of the container with key `x`
357// if no such container exists a negative value is returned
358func (ra *roaringArray) getIndex(x uint16) int {
359 // Todo : test
360 // before the binary search, we optimize for frequent cases
361 size := len(ra.keys)
362 if (size == 0) || (ra.keys[size-1] == x) {
363 return size - 1
364 }
365 return ra.binarySearch(0, int64(size), x)
366}
367
368func (ra *roaringArray) getKeyAtIndex(i int) uint16 {
369 return ra.keys[i]

Callers 11

AddMethod · 0.45
addwithptrMethod · 0.45
CheckedAddMethod · 0.45
RemoveMethod · 0.45
CheckedRemoveMethod · 0.45
CardinalityInRangeMethod · 0.45
FlipMethod · 0.45
AddRangeMethod · 0.45
RemoveRangeMethod · 0.45
FlipFunction · 0.45
appendCopiesAfterMethod · 0.45

Calls 1

binarySearchMethod · 0.95

Tested by

no test coverage detected