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)
| 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 |
| 2899 | func (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 |