public IList(IList <T> list, int start, int count, ILink <T, TResult> factory) { _completed = false; _list = list; _idx = start; checked { _finalIdx = start + count; } _chain = factory.Compose(this); }
public Array(T[] array, int start, int length, ILink <T, TResult> factory) { _completed = false; _idx = start; checked { _endIdx = start + length; } _array = array; _chain = factory.Compose(this); }
public Range(int start, int count, ILink <int, TResult> factory) { Debug.Assert(count > 0); _completed = false; _current = start; _end = unchecked (start + count); _chain = factory.Compose(this); }
public Repeat(T element, int count, ILink <T, TResult> factory) { Debug.Assert(count > 0); _element = element; _current = 0; _end = count; _chain = factory.Compose(this); }
public static void Invoke <V>(int start, int count, ILink <int, V> composition, Chain <V> consumer) => Invoke(start, count, composition.Compose(consumer));
public static void Invoke <TEnumerable, TEnumerator, T, V>(TEnumerable source, ILink <T, V> composition, Chain <V> consumer) where TEnumerable : Optimizations.ITypedEnumerable <T, TEnumerator> where TEnumerator : IEnumerator <T> => Invoke <TEnumerable, TEnumerator, T>(source, composition.Compose(consumer));
public static void Invoke <T, V>(ReadOnlySpan <T> array, ILink <T, V> composition, Chain <V> consumer) => Invoke(array, composition.Compose(consumer));
public static void Invoke <TKey, TElement, TResult, V>(Grouping <TKey, TElement> lastGrouping, Func <TKey, IEnumerable <TElement>, TResult> resultSelector, ILink <TResult, V> composition, Chain <V> consumer) => Invoke(lastGrouping, resultSelector, composition.Compose(consumer));
public static void Invoke <TKey, TElement, V>(Grouping <TKey, TElement> lastGrouping, int count, ILink <IGrouping <TKey, TElement>, V> composition, Chain <V> consumer) => Invoke(lastGrouping, count, composition.Compose(consumer));
public override bool MoveNext() { switch (_state) { case Start: _chain = _link.Compose(this); _link = null; _outer = _consumable.GetEnumerator(); _consumable = null; _state = OuterEnumeratorMoveNext; goto case OuterEnumeratorMoveNext; case OuterEnumeratorMoveNext: if (_outer.MoveNext()) { _inner = _outer.Current.GetEnumerator(); if (ReferenceEquals(_chain, this)) { _state = InnerEnumeratorMoveNextOnSelf; goto case InnerEnumeratorMoveNextOnSelf; } else { _state = InnerEnumeratorMoveNext; goto case InnerEnumeratorMoveNext; } } _state = Completing; goto case Completing; case InnerEnumeratorMoveNextOnSelf: if (!_inner.MoveNext()) { _inner.Dispose(); _inner = default; _state = OuterEnumeratorMoveNext; goto case OuterEnumeratorMoveNext; } Result = (V)(object)_inner.Current; // should be no-op as TResult should equal T return(true); case InnerEnumeratorMoveNext: if (_inner.MoveNext()) { _status = _chain.ProcessNext(_inner.Current); if (_status.IsFlowing()) { _state = CheckStopped; return(true); } _state = CheckStopped; goto case CheckStopped; } _inner.Dispose(); _inner = null; _state = OuterEnumeratorMoveNext; goto case OuterEnumeratorMoveNext; case CheckStopped: if (_status.IsStopped()) { _inner.Dispose(); _inner = null; _state = Completing; goto case Completing; } _state = InnerEnumeratorMoveNext; goto case InnerEnumeratorMoveNext; case Completing: if (_chain.ChainComplete(status & ~ChainStatus.Flow).NotStoppedAndFlowing()) { _state = Finished; return(true); } goto case Finished; case Finished: Result = default; _outer.Dispose(); _outer = null; _chain.ChainDispose(); _chain = null; _state = PostFinished; goto default; default: return(false); } }
public static void Invoke <T, V>(T element, int count, ILink <T, V> composition, Chain <V> consumer) => Invoke(element, count, composition.Compose(consumer));
public override bool MoveNext() { switch (_state) { case Initialization: _chain = _factory.Compose(this); if (_firstOrNull == null) { _enumerator = _second.GetEnumerator(); _second = null; _state = ReadSecondEnumerator; goto case ReadSecondEnumerator; } else { _enumerator = _firstOrNull.GetEnumerator(); _firstOrNull = null; _state = ReadFirstEnumerator; goto case ReadFirstEnumerator; } case ReadFirstEnumerator: if (status.IsStopped()) { _enumerator.Dispose(); _enumerator = null; _state = Completing; goto case Completing; } if (!_enumerator.MoveNext()) { _enumerator.Dispose(); _enumerator = _second.GetEnumerator(); _second = null; _state = ReadSecondEnumerator; goto case ReadSecondEnumerator; } status = _chain.ProcessNext(_enumerator.Current); if (status.IsFlowing()) { return(true); } Debug.Assert(_state == ReadFirstEnumerator); goto case ReadFirstEnumerator; case ReadSecondEnumerator: if (status.IsStopped()) { _enumerator.Dispose(); _enumerator = null; _state = Completing; goto case Completing; } if (!_enumerator.MoveNext()) { _enumerator.Dispose(); if (_thirdOrNull == null) { _enumerator = null; _state = Completing; goto case Completing; } _enumerator = _thirdOrNull.GetEnumerator(); _thirdOrNull = null; _state = ReadThirdEnumerator; goto case ReadThirdEnumerator; } status = _chain.ProcessNext(_enumerator.Current); if (status.IsFlowing()) { return(true); } Debug.Assert(_state == ReadSecondEnumerator); goto case ReadSecondEnumerator; case ReadThirdEnumerator: if (status.IsStopped() || !_enumerator.MoveNext()) { _enumerator.Dispose(); _enumerator = null; _state = Completing; goto case Completing; } status = _chain.ProcessNext(_enumerator.Current); if (status.IsFlowing()) { return(true); } Debug.Assert(_state == ReadThirdEnumerator); goto case ReadThirdEnumerator; case Completing: if (_chain.ChainComplete(status & ~ChainStatus.Flow).NotStoppedAndFlowing()) { _state = Finished; return(true); } goto case Finished; case Finished: Result = default; _state = PostFinished; return(false); default: return(false); } }
public static void Invoke <T, V>(IList <T> array, int start, int count, ILink <T, V> composition, Chain <V> consumer) => Invoke(array, start, count, composition.Compose(consumer));