Exemplo n.º 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>()));
 }