MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / binaryIndex

Function binaryIndex

lib/web/jshint.js:4347–4365  ·  view source on GitHub ↗

* Performs a binary search of `array` to determine the index at which `value` * should be inserted into `array` in order to maintain its sort order. * * @private * @param {Array} array The sorted array to inspect. * @param {*} value The value to evaluate. * @param {bool

(array, value, retHighest)

Source from the content-addressed store, hash-verified

4345 * into `array`.
4346 */
4347 function binaryIndex(array, value, retHighest) {
4348 var low = 0,
4349 high = array ? array.length : low;
4350
4351 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
4352 while (low < high) {
4353 var mid = (low + high) >>> 1,
4354 computed = array[mid];
4355
4356 if (retHighest ? (computed <= value) : (computed < value)) {
4357 low = mid + 1;
4358 } else {
4359 high = mid;
4360 }
4361 }
4362 return high;
4363 }
4364 return binaryIndexBy(array, value, identity, retHighest);
4365 }
4366
4367 /**
4368 * This function is like `binaryIndex` except that it invokes `iteratee` for

Callers 3

createSortedIndexFunction · 0.85
indexOfFunction · 0.85
lastIndexOfFunction · 0.85

Calls 1

binaryIndexByFunction · 0.85

Tested by

no test coverage detected