MCPcopy
hub / github.com/lengstrom/falcon / binarySearch

Function binarySearch

extension/js/background.js:337–352  ·  view source on GitHub ↗
(arr, value, lt, gt, i, j)

Source from the content-addressed store, hash-verified

335}
336
337function binarySearch(arr, value, lt, gt, i, j) {
338 if (Math.abs(j - i) <= 1) {
339 return (i + j)/2;
340 }
341
342 var m = Math.floor((i + j)/2)
343 var cmpVal = arr[m];
344 if (gt(cmpVal, value)) {
345 j = m;
346 } else if (lt(cmpVal, value)){
347 i = m;
348 } else {
349 return m;
350 }
351 return binarySearch(arr, value, lt, gt, i, j);
352}
353
354init();

Callers 2

makePreloadedFunction · 0.85
dispatchSuggestionsFunction · 0.85

Calls 2

gtFunction · 0.85
ltFunction · 0.85

Tested by

no test coverage detected