Skip to main content
Module

x/structurae/index.ts>SortedArray.getIntersection

Data structures for high-performance JavaScript applications.
Latest
method SortedArray.getIntersection
import { SortedArray } from "https://deno.land/x/structurae@4.0.1/index.ts";

Returns the intersection of two sorted arrays.

Examples

SortedArray.getIntersection([1, 2, 3, 4, 8], [2, 4, 6, 7, 9]); //=> [ 2, 4 ]

// intersection using a custom comparator: const customComparator = (a, b) => (a > b ? -1 : a < b ? 1 : 0); SortedArray.getIntersection([8, 4, 3, 2, 1], [9, 7, 6, 4, 2], customComparator); //=> [ 4, 2 ]

Parameters

a: U

the first array

b: U

the second array

optional
comparator: Comparator<T> = [UNSUPPORTED]
optional
container: U = [UNSUPPORTED]

Returns

the intersection of the arrays