in pkg/timestamp/range.go [143:169]
func FindRange[T int64 | uint64](timestamps []T, minVal, maxVal T) (int, int, bool) {
if len(timestamps) == 0 {
return -1, -1, false
}
isAsc := timestamps[0] <= timestamps[len(timestamps)-1]
if isAsc && (timestamps[0] > maxVal || timestamps[len(timestamps)-1] < minVal) {
return -1, -1, false
}
if !isAsc && (timestamps[0] < minVal || timestamps[len(timestamps)-1] > maxVal) {
return -1, -1, false
}
start, end := -1, len(timestamps)
for start < len(timestamps)-1 {
start++
if isAsc && timestamps[start] >= minVal || !isAsc && timestamps[start] <= maxVal {
break
}
}
for end > 0 {
end--
if isAsc && timestamps[end] <= maxVal || !isAsc && timestamps[end] >= minVal {
break
}
}
return start, end, start <= end
}