public static void ForEach <T>(this IFiniteYielder <T> source, Action <T> action) { while (source.HasNext()) { action(source.Next()); } }
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()); }
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); }
public static int Count <T>(this IFiniteYielder <T> source) { int count = 0; while (source.HasNext()) { checked { count++; } source.Next(); } return(count); }
public static bool Any <T>(this IFiniteYielder <T> source, Predicate <T> predicate) { while (source.HasNext()) { if (predicate(source.Next())) { return(true); } } return(false); }
public bool HasNext() { if (_first) { for (int i = 0; i < _count; ++i) { if (_source.HasNext()) { _source.Next(); } else { break; } } _first = false; } return(_source.HasNext()); }
public TResult Next() => _fun(_source.Next());