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

Method previousValue

runcontainer.go:2899–2914  ·  view source on GitHub ↗

previousValue will return the previous present value If the target is in the interior of a run then `target` will be returned Example: If our run structure resmembles [[a,c], [d,f]] with a <= target <= c then target will be returned. If c < target < d then c is returned. if target > f then f is r

(target uint16)

Source from the content-addressed store, hash-verified

2897// if target > f then f is returned
2898// if the target is less than a, this is out of bounds and -1 is returned
2899func (rc *runContainer16) previousValue(target uint16) int {
2900 whichIndex, alreadyPresent, _ := rc.search(int(target))
2901
2902 if len(rc.iv) == 0 {
2903 return int(target)
2904 }
2905
2906 if alreadyPresent {
2907 return int(target)
2908 }
2909 if whichIndex == -1 {
2910 return -1
2911 }
2912
2913 return int(rc.iv[whichIndex].last())
2914}
2915
2916// previousAbsentValue will return the previous absent value
2917// If the target is in the interior of a run then then the start of the range minus 1 will be returned

Callers

nothing calls this directly

Calls 2

searchMethod · 0.95
lastMethod · 0.80

Tested by

no test coverage detected