Beispiel #1
0
 public static void ForEach <T>(this IFiniteYielder <T> source, Action <T> action)
 {
     while (source.HasNext())
     {
         action(source.Next());
     }
 }
        public FiniteYielderTaker(IFiniteYielder <T> source, int limit)
        {
            _source = source;
            _limit  = limit;

            _count = 0;
        }
Beispiel #3
0
        public FiniteYielderSkipper(IFiniteYielder <T> source, int count)
        {
            _source = source;
            _count  = count;

            _first = true;
        }
Beispiel #4
0
        public static List <T> ToList <T>(this IFiniteYielder <T> source)
        {
            var rv = new List <T>();

            while (source.HasNext())
            {
                rv.Add(source.Next());
            }
            return(rv);
        }
Beispiel #5
0
        public static bool Contains <T>(this IFiniteYielder <T> source, T item, IEqualityComparer <T> comp)
        {
            while (source.HasNext())
            {
                if (comp.Equals(item, source.Next()))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #6
0
        public static int Count <T>(this IFiniteYielder <T> source)
        {
            int count = 0;

            while (source.HasNext())
            {
                checked { count++; }
                source.Next();
            }

            return(count);
        }
Beispiel #7
0
        public static bool Any <T>(this IFiniteYielder <T> source, Predicate <T> predicate)
        {
            while (source.HasNext())
            {
                if (predicate(source.Next()))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #8
0
 public static bool Contains <T>(this IFiniteYielder <T> source, T item)
 {
     return(Contains(source, item, EqualityComparer <T> .Default));
 }
Beispiel #9
0
 public static IFiniteYielder <T> TakeWhile <T>(this IFiniteYielder <T> source, Predicate <T> predicate)
 {
     return(new FiniteYielderWhileTaker <T>(source, predicate));
 }
Beispiel #10
0
 public static IFiniteYielder <T> Take <T>(this IFiniteYielder <T> source, int count)
 {
     return(new FiniteYielderTaker <T>(source, count));
 }
Beispiel #11
0
 public static IFiniteYielder <TResult> OfType <TSource, TResult>(this IFiniteYielder <TSource> source) where TResult : TSource
 {
     return(new FiniteYielderOfTypeSelector <TSource, TResult>(source));
 }
Beispiel #12
0
 public static IFiniteYielder <T> Skip <T>(this IFiniteYielder <T> source, int count)
 {
     return(new FiniteYielderSkipper <T>(source, count));
 }
Beispiel #13
0
 public static IFiniteYielder <T> Filter <T>(this IFiniteYielder <T> source, Predicate <T> predicate)
 {
     return(new FiniteYielderFilter <T>(source, predicate));
 }
Beispiel #14
0
 public static IFiniteYielder <TResult> Map <TSource, TResult>(this IFiniteYielder <TSource> source, Func <TSource, TResult> fun)
 {
     return(new FiniteYielderMapper <TSource, TResult>(source, fun));
 }
Beispiel #15
0
 public FiniteYielderMapper(IFiniteYielder <TSource> source, Func <TSource, TResult> fun)
 {
     _source = source;
     _fun    = fun;
 }
Beispiel #16
0
        public FiniteYielderFilter(IFiniteYielder <T> source, Predicate <T> predicate)
        {
            _source    = source;
            _predicate = predicate;

            _next           = default !;
Beispiel #17
0
        public FiniteYielderOfTypeSelector(IFiniteYielder <TSource> source)
        {
            _source = source;

            _next           = default !;