import { EnumerableFactory } from '../utilities/EnumerableFactory'; import { IEnumerable } from '../types'; import { EqualityComparer } from '../types'; import { applyIntersect } from './applicators/applyIntersect'; /** * Produces the set intersection of two sequences. * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersect(src: Iterable, second: Iterable): IEnumerable; /** * Produces the set intersection of two sequences. * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersect(src: Iterable, ...second: Iterable[]): IEnumerable; /** * Produces the set intersection of two sequences. * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param equalityComparer A function to compare keys. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersect( src: Iterable, second: Iterable, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set intersection of two sequences. * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param third An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param equalityComparer A function to compare keys. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersect( src: Iterable, second: Iterable, third: Iterable, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set intersection of two sequences. * @typeparam TSource The type of source elements. * @param src The source iterable. * @param second An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param third An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param fourth An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param equalityComparer A function to compare keys. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersect( src: Iterable, second: Iterable, third: Iterable, fourth: Iterable, equalityComparer: EqualityComparer ): IEnumerable; export function intersect( src: Iterable, ...second: (Iterable | EqualityComparer)[] ): IEnumerable { return applyIntersect(new EnumerableFactory(), x => x, src, second); } /** * Produces the set intersection 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 that also appear in the first sequence will be returned. * @param keySelector A function to extract the key for each element. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersectBy( src: Iterable, second: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set intersection 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 that also appear in the first sequence will be returned. * @param third An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param keySelector A function to extract the key for each element. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersectBy( src: Iterable, second: Iterable, third: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set intersection 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 that also appear in the first sequence will be returned. * @param third An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param fourth An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param keySelector A function to extract the key for each element. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersectBy( src: Iterable, second: Iterable, third: Iterable, fourth: Iterable, keySelector: (item: TSource) => TKey ): IEnumerable; /** * Produces the set intersection 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 that also appear in the first sequence will be returned. * @param keySelector A function to extract the key for each element. * @param equalityComparer A function to compare keys. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersectBy( src: Iterable, second: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set intersection 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 that also appear in the first sequence will be returned. * @param third An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param keySelector A function to extract the key for each element. * @param equalityComparer A function to compare keys. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersectBy( src: Iterable, second: Iterable, third: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; /** * Produces the set intersection 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 that also appear in the first sequence will be returned. * @param third An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param fourth An IEnumerable whose distinct elements that also appear in the first sequence will be returned. * @param keySelector A function to extract the key for each element. * @param equalityComparer A function to compare keys. * @returns A sequence that contains the elements that form the set intersection of two sequences. */ export function intersectBy( src: Iterable, second: Iterable, third: Iterable, fourth: Iterable, keySelector: (item: TSource) => TKey, equalityComparer: EqualityComparer ): IEnumerable; export function intersectBy( src: Iterable, ...second: (Iterable | ((item: TSource) => TKey) | EqualityComparer)[] ): IEnumerable { return applyIntersect(new EnumerableFactory(), null, src, second); }