Пример #1
0
        private static IEnumerable <TSource> ExceptImpl <TSource>(this IEnumerable <TSource> first, IEnumerable <TSource> second, IEqualityComparer <TSource> comparer)
        {
            var hashSetFromFirstSequence = new HashSet <TSource>(second, comparer);

            return(first.SelectMany(element =>
                                    hashSetFromFirstSequence.Add(element) ?
                                    SelectManyEnumerable.Repeat(element, 1) :
                                    SelectManyEnumerable.Empty <TSource>()));
        }
 public static IEnumerable <TSource> Where <TSource>(this IEnumerable <TSource> source, Func <TSource, bool> predicate)
 {
     return(source.SelectMany(elem => predicate(elem) ?
                              SelectManyEnumerable.Repeat(elem, 1) :
                              SelectManyEnumerable.Empty <TSource>()));
 }
Пример #3
0
 public static IEnumerable <TResult> Select <TSource, TResult>(this IEnumerable <TSource> source, Func <TSource, TResult> selector)
 {
     return(source.SelectMany(elem => SelectManyEnumerable.Repeat(selector(elem), 1)));
 }