Skip to main content
Module

x/structurae/sorted-array.ts>SortedArray.getUnion

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

Returns the union of two sorted arrays as a sorted array.

Examples

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

// union of sorted arrays without duplicates: SortedArray.getUnion([1, 2, 3, 4, 8], [2, 4, 6, 7, 9], true); //=> [ 1, 2, 3, 4, 6, 7, 8, 9 ]

//union using a custom comparator: SortedArray.getUnion([8, 4, 3, 2, 1], [9, 7, 6, 4, 2], true, customComparator); //=> [ 9, 8, 7, 6, 4, 3, 2, 1 ]

Parameters

the first array

the second array

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

Returns

the union of the arrays