예제 #1
0
 public static void ForEach <T>(this IFiniteYielder <T> source, Action <T> action)
 {
     while (source.HasNext())
     {
         action(source.Next());
     }
 }
예제 #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);
        }
예제 #3
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);
        }
예제 #4
0
        public static int Count <T>(this IFiniteYielder <T> source)
        {
            int count = 0;

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

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

            return(false);
        }
예제 #6
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());
        }
예제 #7
0
 public bool HasNext() => _source.HasNext();
 public bool HasNext()
 {
     return(_source.HasNext() && _count < _limit);
 }