Package Exports
- binary-search-bounds
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (binary-search-bounds) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
binary-search-bounds
Binary search on arrays.
API
var bounds = require("binary-search-bounds")
bounds.lt(array, y[, cmp, lo, hi])
Returns the index of the last item in the array <
y
bounds.le(array, y[, cmp, lo, hi])
Returns the index of the last item in the array <=
y
bounds.gt(array, y[, cmp, lo, hi])
Returns the index of the first item in the array >
y
bounds.ge(array, y[, cmp, lo, hi])
Returns the index of the first item in the array >=
y
Notes
cmp
is a comparison function, just like what you would pass toArray.sort()
y
will always be the second argument passed tocmp
, so you can ignore it if you are just binary searching on a predicatelo
gives a lower bound on the array index to searchhi
gives an upper bound on the array index to searchbounds.le
andbounds.lt
will returnlo - 1
if no element is found satisfying the predicatebounds.ge
andbounds.gt
will returnhi + 1
if no element is found satisfying the predicate
Credits
(c) 2013 Mikola Lysenko. MIT License