dieumercimvemba's picture
download
raw
560 Bytes
// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound
// Used to compute insertion index to keep queue sorted after insertion
export default function lowerBound(array, value, comparator) {
let first = 0;
let count = array.length;
while (count > 0) {
const step = Math.trunc(count / 2);
let it = first + step;
if (comparator(array[it], value) <= 0) {
first = ++it;
count -= step + 1;
}
else {
count = step;
}
}
return first;
}

Xet Storage Details

Size:
560 Bytes
·
Xet hash:
85dbd3b2057b67d4f38efeb3f5267d6cf9c9a4e2cc6b10cdb3a9f5053d6674fc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.