Ejemplo n.º 1
0
                /// <summary>
                /// Advances the enumerator to the next element of the collection.
                /// </summary>
                /// <returns>
                /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
                /// </returns>
                /// <exception cref="InvalidOperationException">The collection was modified after the enumerator was created. </exception>
                public bool MoveNext()
                {
                    this.ThrowIfDisposed();
                    if (_bucket.IsEmpty)
                    {
                        _currentPosition = Position.End;
                        return(false);
                    }

                    switch (_currentPosition)
                    {
                    case Position.BeforeFirst:
                        _currentPosition = Position.First;
                        return(true);

                    case Position.First:
                        if (_bucket._additionalElements.IsEmpty)
                        {
                            _currentPosition = Position.End;
                            return(false);
                        }

                        _currentPosition      = Position.Additional;
                        _additionalEnumerator = new ImmutableList <T> .Enumerator(_bucket._additionalElements);

                        return(_additionalEnumerator.MoveNext());

                    case Position.Additional:
                        return(_additionalEnumerator.MoveNext());

                    case Position.End:
                        return(false);

                    default:
                        throw new InvalidOperationException();
                    }
                }