-
Notifications
You must be signed in to change notification settings - Fork 0
rangedMerge
Subhajit Sahu edited this page Jun 19, 2020
·
1 revision
Merge ranges of values from two sorted arrays.
Similar: [merge], [mergeAll], rangedMerge.
function rangedMerge(x, i, I, y, j, J, fc, fm)
// x: an array
// i: begin index in x
// I: end index in x (exclusive)
// y: another array
// j: begin index in y
// J: end index in y (exclusive)
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xsortedArray = require('extra-sorted-array');
var x = [10, 20, 20, 40, 40, 80];
var y = [20, 50, 70];
xsortedArray.rangedMerge(x, 0, 3, y, 0, 3);
// → [ 10, 20, 20, 20, 50, 70 ]
xsortedArray.rangedMerge(x, 0, 2, x, 4, 6);
// → [ 10, 20, 40, 80 ]