herald.go/internal/sort.go
Jeffrey Picard 167f62c845 More cleanup
2022-04-11 01:40:29 +00:00

11 lines
394 B
Go

package internal
import "sort"
// BisectRight returns the index of the first element in the list that is greater than or equal to the value.
// https://stackoverflow.com/questions/29959506/is-there-a-go-analog-of-pythons-bisect-module
func BisectRight(arr []interface{}, val uint32) uint32 {
i := sort.Search(len(arr), func(i int) bool { return arr[i].(uint32) >= val })
return uint32(i)
}