MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / _binarySearch

Function _binarySearch

public/javascripts/async.js:999–1011  ·  view source on GitHub ↗
(sequence, item, compare)

Source from the content-addressed store, hash-verified

997 }
998
999 function _binarySearch(sequence, item, compare) {
1000 var beg = -1,
1001 end = sequence.length - 1;
1002 while (beg < end) {
1003 var mid = beg + ((end - beg + 1) >>> 1);
1004 if (compare(item, sequence[mid]) >= 0) {
1005 beg = mid;
1006 } else {
1007 end = mid - 1;
1008 }
1009 }
1010 return beg;
1011 }
1012
1013 function _insert(q, data, priority, callback) {
1014 if (callback != null && typeof callback !== "function") {

Callers 1

_insertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected