UpperBound returns the index of the first element in vector[first, last) that is greater than 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/l
(first int, last int, value unsafe.Pointer)
| 235 | // order. If all values in the given range is less than the given value, LowerBound returns last. |
| 236 | // Note that first/last is not checked against vector bound. |
| 237 | func (v *Vector) UpperBound(first int, last int, value unsafe.Pointer) int { |
| 238 | for first < last { |
| 239 | mid := (last + first) / 2 |
| 240 | |
| 241 | cmpRes := 0 |
| 242 | if v.DataType == common.Bool { |
| 243 | cmpRes = common.CompareBool(v.GetBool(mid), *(*uint32)(value) != 0) |
| 244 | } else { |
| 245 | cmpRes = v.CmpFunc(v.GetValue(mid), value) |
| 246 | } |
| 247 | |
| 248 | if cmpRes > 0 { |
| 249 | last = mid |
| 250 | } else { |
| 251 | first = mid + 1 |
| 252 | } |
| 253 | } |
| 254 | return first |
| 255 | } |
| 256 | |
| 257 | // GetSliceBytesAligned calculate the number of bytes of a slice of the vector, |
| 258 | // represented by [lowerBound, upperBound), |
no test coverage detected