Ejemplo 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>()));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var enumerable = SelectManyEnumerable.Range(1, 10);
            var a          = SelectManyEnumerable.Count(enumerable);

            var first  = SelectManyEnumerable.Range(1, 5);
            var second = SelectManyEnumerable.Range(1, 3);

            var concat = SelectManyEnumerable.Concat(first, second);

            var except = first.Except(second).ToArray();

            Console.WriteLine("Hello World!");
        }
 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>()));
 }
Ejemplo n.º 4
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)));
 }