Exemplo n.º 1
0
        /// <summary>
        /// Advances the enumerator to the next element of the <see cref="IPartition{T}"/>. If there are no more elements, does nothing.
        /// </summary>
        /// <param name="partition">The <see cref="IPartition{T}"/> object over which this enumerator is iterating.</param>
        public void MoveNext(IPartition <T> partition)
        {
            if (partition == null || Enumerator == null)
            {
                return;
            }

            if (SegmentCount > 0)
            {
                SegmentCount--;

                bool Moved = Enumerator.MoveNext();
                Debug.Assert(Moved);

                return;
            }

            SegmentIndex = partition.NextSegmentIndex(SegmentIndex);
            if (SegmentIndex < 0)
            {
                Enumerator = null;
                return;
            }

            Enumerator = partition.GetSegmentEnumerator(SegmentIndex, 0, out SegmentCount);
            Enumerator.MoveNext();

            Debug.Assert(SegmentCount > 0);
            SegmentCount--;
        }