import { EnumerableFactory } from '../utilities/EnumerableFactory'; import { IEnumerable } from '../types'; import { EqualityComparer } from '../types'; import { applyUnion } from './applicators/applyUnion'; /** * Produces the set union of two sequences. * @typeparam TSource The type of source elements. * @param src The source Iterable * @param second One or more Iterable whose distinct elements form the second set for the union. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function union(src: Iterable, second: Iterable): IEnumerable; /** * Produces the set union of two or more sequences. * @typeparam TSource The type of source elements. * @param src The source Iterable * @param second One or more Iterable whose distinct elements form the second set for the union. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function union(src: Iterable, ...second: Iterable[]): IEnumerable; /** * Produces the set union of two sequences. * @typeparam TSource The type of source elements. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param equalityComparer The EqualityComparer to compare values. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function union( src: Iterable, second: Iterable, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set union of two sequences. * @typeparam TSource The type of source elements. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param third An IEnumerable whose distinct elements form the third set for the union. * @param equalityComparer The EqualityComparer to compare values. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function union( src: Iterable, second: Iterable, third: Iterable, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set union of two sequences. * @typeparam TSource The type of source elements. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param third An IEnumerable whose distinct elements form the third set for the union. * @param fourth An IEnumerable whose distinct elements form the fourth set for the union. * @param equalityComparer The EqualityComparer to compare values. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function union( src: Iterable, second: Iterable, third: Iterable, fourth: Iterable, equalityComparer: EqualityComparer ): IEnumerable; export function union( src: Iterable, ...second: (Iterable | EqualityComparer)[] ): IEnumerable { return applyUnion(new EnumerableFactory(), (x: TSource) => x, src, second); } /** * Produces the set union of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param keySelector A function to extract the key for each element. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function unionBy( src: Iterable, second: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set union of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param third An IEnumerable whose distinct elements form the third set for the union. * @param keySelector A function to extract the key for each element. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function unionBy( src: Iterable, second: Iterable, third: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set union of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param third An IEnumerable whose distinct elements form the third set for the union. * @param fourth An IEnumerable whose distinct elements form the fourth set for the union. * @param keySelector A function to extract the key for each element. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function unionBy( src: Iterable, second: Iterable, third: Iterable, fourth: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set union of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param keySelector A function to extract the key for each element. * @param equalityComparer The EqualityComparer to compare values. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function unionBy( src: Iterable, second: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set union of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param third An IEnumerable whose distinct elements form the third set for the union. * @param keySelector A function to extract the key for each element. * @param equalityComparer The EqualityComparer to compare values. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function unionBy( src: Iterable, second: Iterable, third: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set union of two sequences according to a specified key selector function. * @typeparam TSource The type of source elements. * @typeparam TKey The type of key to identify elements by. * @param src The source Iterable * @param second An IEnumerable whose distinct elements form the second set for the union. * @param third An IEnumerable whose distinct elements form the third set for the union. * @param fourth An IEnumerable whose distinct elements form the fourth set for the union. * @param keySelector A function to extract the key for each element. * @param equalityComparer The EqualityComparer to compare values. * @returns An IEnumerable that contains the elements from both input sequences, excluding duplicates. */ export function unionBy( src: Iterable, second: Iterable, third: Iterable, fourth: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; export function unionBy( src: Iterable, ...second: (Iterable | ((item: TSource) => TKey) | EqualityComparer)[] ): IEnumerable { return applyUnion(new EnumerableFactory(), null, src, second); }