import { SortedArray } from "https://deno.land/x/structurae@4.0.1/index.ts";
Returns the difference of two sorted arrays,
i.e. elements present in the first array but not in the second array.
If symmetric=true
finds the symmetric difference of two arrays, that is,
the elements that are absent in one or another array.
Examples
SortedArray.getDifference([1, 2, 3, 4, 8], [2, 4, 6, 7, 9]);
//=> [ 1, 3, 8 ]
SortedArray.getDifference([1, 2, 3, 4, 8], [2, 4, 6, 7, 9]); //=> [ 1, 3, 8 ]
// symmetric difference of sorted arrays: SortedArray.getDifference(first, second, true); //=> [ 1, 3, 6, 7, 8, 9 ]
// difference using a custom comparator: const customComparator = (a, b) => (a > b ? -1 : a < b ? 1 : 0); SortedArray.getDifference([8, 4, 3, 2, 1], [9, 7, 6, 4, 2], false, customComparator); //=> [ 8, 3, 1 ]
Type Parameters
U extends IndexedCollection<T>
Parameters
optional
comparator: Comparator<T> = [UNSUPPORTED]optional
container: U = [UNSUPPORTED]