Skip to content

Commit

Permalink
util: Remove unused code for lower_bound.
Browse files Browse the repository at this point in the history
We currently do not need support for passing first and last index to
the lower_bound function, so we just remove it.
  • Loading branch information
priyank-p authored and timabbott committed Jul 2, 2021
1 parent 782fca7 commit cfc2d7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
1 change: 0 additions & 1 deletion frontend_tests/node_tests/util.js
Expand Up @@ -51,7 +51,6 @@ run_test("lower_bound", () => {
assert.equal(util.lower_bound(arr, 15), 1);
assert.equal(util.lower_bound(arr, 50), 4);
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}];

Expand Down
21 changes: 3 additions & 18 deletions static/js/util.js
Expand Up @@ -15,24 +15,9 @@ export function random_int(min, max) {
// for some i and false otherwise.
//
// Usage: lower_bound(array, value, [less])
// lower_bound(array, first, last, value, [less])
export function lower_bound(array, arg1, arg2, arg3, arg4) {
let first;
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;
}

export function lower_bound(array, value, less) {
let first = 0;
const last = array.length;
if (less === undefined) {
less = function (a, b) {
return a < b;
Expand Down

0 comments on commit cfc2d7c

Please sign in to comment.