sorted-intersect
Version:
Intersect sorted lists using merge intersection with galloping lookahead
40 lines (27 loc) • 771 B
Markdown
using merge intersection with galloping lookahead.
npm install sorted-intersect
It is useful if you want to (efficiently) intersect large, sorted lists.
## Usage
It is easy to use
``` js
var intersect = require('sorted-intersect');
var intersection = intersect([
[ ], // these lists should be sorted
[ ],
[ ],
[ ]
]);
console.log(intersection); // prints [7,8,10]
```
`intersect(lists, options)` takes an optional second parameter
which can contain the following options
``` js
{
limit: number, // limit the result to this number
marker: value, // start the intersection a this value,
offsets: [] // use these list offsets (mutates the array)
}
```
MIT
Intersect sorted lists