Exemplo n.º 1
0
 public static void ForEach <T>(this IFiniteYielder <T> source, Action <T> action)
 {
     while (source.HasNext())
     {
         action(source.Next());
     }
 }
Exemplo n.º 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());
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        public static int Count <T>(this IFiniteYielder <T> source)
        {
            int count = 0;

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

            return(count);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
        }
Exemplo n.º 8
0
 public TResult Next() => _fun(_source.Next());