Exemple #1
0
 public static void ForEach <T>(this IFiniteYielder <T> source, Action <T> action)
 {
     while (source.HasNext())
     {
         action(source.Next());
     }
 }
Exemple #2
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);
        }
        public T Next()
        {
            if (!_source.HasNext())
            {
                throw new InvalidOperationException();
            }

            ++_count;
            return(_source.Next());
        }
Exemple #4
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);
        }
Exemple #5
0
        public static int Count <T>(this IFiniteYielder <T> source)
        {
            int count = 0;

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

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

            return(false);
        }
Exemple #7
0
        public bool HasNext()
        {
            if (_first)
            {
                for (int i = 0; i < _count; ++i)
                {
                    if (_source.HasNext())
                    {
                        _source.Next();
                    }
                    else
                    {
                        break;
                    }
                }

                _first = false;
            }

            return(_source.HasNext());
        }
Exemple #8
0
 public TResult Next() => _fun(_source.Next());