示例#1
0
        /// <summary>
        /// Sets the enumerator to its initial position.
        /// </summary>
        /// <param name="unshuffle">Indicates whether elements will be returned to their original, unshuffled, positions.</param>
        public void Reset(bool unshuffle)
        {
            if (unshuffle)
            {
                var lastIndex  = (m_offset + m_count);
                var leftIndex  = m_offset;
                var rightIndex = ++m_position;

                while (rightIndex < lastIndex)
                {
                    m_randomNumberGenerator.Jump(-1);

                    var randomIndex = m_randomNumberGenerator.NextInt32(leftIndex, rightIndex);
                    var tempValue   = m_list[randomIndex];

                    m_list[randomIndex]  = m_list[rightIndex];
                    m_list[rightIndex++] = tempValue;

                    m_randomNumberGenerator.Jump(-1);
                }
            }

            m_position = (m_offset + m_count);
        }