chickadee » srfi-214 » flexvector-binary-search

Similar to flexvector-index and flexvector-index-right, but, instead of searching left-to-right or right-to-left, this performs a binary search. If there is more than one element of fv that matches value in the sense of cmp, flexvector-binary-search may return the index of any of them. The search is performed on only the indexes of fv between start, which defaults to 0, and end, which defaults to the length of fv. Both start and end are clamped to the range [0, (flexvector-length fv)]. It is an error if end is less than start. cmp should be a procedure of two arguments that returns either a negative integer, which indicates that its first argument is less than its second; zero, which indicates that they are equal; or a positive integer, which indicates that the first argument is greater than the second argument. An example cmp might be: