github.com/fufuok/balancer@v1.0.0/utils/integer.go (about) 1 package utils 2 3 // SearchInts similar to sort.SearchInts(), but faster. 4 func SearchInts(a []int, x int) (i int) { 5 j := len(a) 6 for i < j { 7 h := int(uint(i+j) >> 1) 8 if a[h] < x { 9 i = h + 1 10 } else { 11 j = h 12 } 13 } 14 return i 15 }