util: Remove unused code for lower_bound.

We currently do not need support for passing first and last index to
the lower_bound function, so we just remove it.
This commit is contained in:
Priyank Patel
2021-07-02 17:50:45 +00:00
committed by Tim Abbott
parent 782fca79c4
commit cfc2d7c842
2 changed files with 3 additions and 19 deletions

View File

@@ -51,7 +51,6 @@ run_test("lower_bound", () => {
assert.equal(util.lower_bound(arr, 15), 1); assert.equal(util.lower_bound(arr, 15), 1);
assert.equal(util.lower_bound(arr, 50), 4); assert.equal(util.lower_bound(arr, 50), 4);
assert.equal(util.lower_bound(arr, 55), 5); assert.equal(util.lower_bound(arr, 55), 5);
assert.equal(util.lower_bound(arr, 2, 4, 31), 3);
arr = [{x: 10}, {x: 20}, {x: 30}]; arr = [{x: 10}, {x: 20}, {x: 30}];

View File

@@ -15,24 +15,9 @@ export function random_int(min, max) {
// for some i and false otherwise. // for some i and false otherwise.
// //
// Usage: lower_bound(array, value, [less]) // Usage: lower_bound(array, value, [less])
// lower_bound(array, first, last, value, [less]) export function lower_bound(array, value, less) {
export function lower_bound(array, arg1, arg2, arg3, arg4) { let first = 0;
let first; const last = array.length;
let last;
let value;
let less;
if (arg3 === undefined) {
first = 0;
last = array.length;
value = arg1;
less = arg2;
} else {
first = arg1;
last = arg2;
value = arg3;
less = arg4;
}
if (less === undefined) { if (less === undefined) {
less = function (a, b) { less = function (a, b) {
return a < b; return a < b;