/// <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--;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PartitionEnumerator{T}"/> class.
        /// Creates an instance that enumerates objects starting at the specified position in <see cref="IPartition{T}"/>.
        /// </summary>
        /// <param name="partition">The enumerated partition.</param>
        /// <param name="segmentIndex">The segment index of the position of the first element to enumerate.</param>
        /// <param name="elementIndex">The element index of the position of the first element to enumerate.</param>
        public PartitionEnumerator(IPartition <T> partition, int segmentIndex, int elementIndex)
        {
            Debug.Assert(partition.IsValidPosition(segmentIndex, elementIndex, false));

            Partition    = partition;
            SegmentIndex = segmentIndex;

            Enumerator = partition.GetSegmentEnumerator(segmentIndex, elementIndex, out SegmentCount);
        }