"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.binaryFindIndex = binaryFindIndex;
function binaryFindIndex(arr, predicate) {
    let upper_bound = arr.length;
    let lower_bound = 0;
    let i = -1;
    while (true) {
        i = Math.floor((upper_bound + lower_bound) / 2);
        const element = arr[i];
        const score = predicate(element, i);
        if (score === 0) {
            return i;
        }
        else if (score > 0) {
            upper_bound = i;
        }
        else {
            lower_bound = i;
        }
        if (upper_bound <= lower_bound || i >= lower_bound) {
            break;
        }
    }
    return i;
}
//# sourceMappingURL=sort.js.map