LowerBound returns the index of the first element in vector[first, last) that is greater or equal to the given value. The result is only valid if vector[first, last) is fully sorted in ascendant order. If all values in the given range is less than the given value, LowerBound returns last. Note that
(first int, last int, value unsafe.Pointer)
| 212 | // returns last. |
| 213 | // Note that first/last is not checked against vector bound. |
| 214 | func (v *Vector) LowerBound(first int, last int, value unsafe.Pointer) int { |
| 215 | for first < last { |
| 216 | mid := (last + first) / 2 |
| 217 | cmpRes := 0 |
| 218 | if v.DataType == common.Bool { |
| 219 | cmpRes = common.CompareBool(v.GetBool(mid), *(*uint32)(value) != 0) |
| 220 | } else { |
| 221 | cmpRes = v.CmpFunc(v.GetValue(mid), value) |
| 222 | } |
| 223 | |
| 224 | if cmpRes >= 0 { |
| 225 | last = mid |
| 226 | } else { |
| 227 | first = mid + 1 |
| 228 | } |
| 229 | } |
| 230 | return first |
| 231 | } |
| 232 | |
| 233 | // UpperBound returns the index of the first element in vector[first, last) that is greater than the |
| 234 | // given value. The result is only valid if vector[first, last) is fully sorted in ascendant |
no test coverage detected