MCPcopy
hub / github.com/DHTMLX/gantt / findFirst

Function findFirst

samples/common/codehighlight/codemirror.js:300–311  ·  view source on GitHub ↗
(pred, from, to)

Source from the content-addressed store, hash-verified

298 // `pred` and is closest to `from`. Assumes that at least `to`
299 // satisfies `pred`. Supports `from` being greater than `to`.
300 function findFirst(pred, from, to) {
301 // At any point we are certain `to` satisfies `pred`, don't know
302 // whether `from` does.
303 var dir = from > to ? -1 : 1;
304 for (;;) {
305 if (from == to) { return from }
306 var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
307 if (mid == from) { return pred(mid) ? from : to }
308 if (pred(mid)) { to = mid; }
309 else { from = mid + dir; }
310 }
311 }
312
313 // BIDI HELPERS
314

Callers 4

wrappedLineExtentFunction · 0.85
coordsCharInnerFunction · 0.85
coordsBidiPartFunction · 0.85
endOfLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected