ShuffleBag (Fisher-Yates + PcgRandom) Anything that could be done better here?

public class ShuffleBag&lt;T&gt; : IEnumerable&lt;T&gt;
{
    private readonly int m_endIndex;
    private readonly FastRandom m_rng;
    private readonly T[] m_values;

    private int m_currentIndex;

    public ShuffleBag(T[] values, ulong state, ulong? stream = null) {
        m_currentIndex = 0;
        m_endIndex = (values.Length - 1);
        m_rng = (stream.HasValue ? new FastRandom(state, stream.Value) : new FastRandom(state));
        m_values = values;
    }
    public ShuffleBag(T[] values) : this(values, SecureRandom.GetUInt64()) { }

    IEnumerator IEnumerable.GetEnumerator() {
        return GetEnumerator();
    }
    public IEnumerator&lt;T&gt; GetEnumerator() {
        var currentIndex = m_currentIndex;
        var endIndex = m_endIndex;
        var rng = m_rng;
        var values = m_values;

        while (currentIndex &lt;= endIndex) {
            var randomIndex = rng.NextInt32(currentIndex, endIndex);
            var temp = values[randomIndex];

            values[randomIndex] = values[currentIndex];
            values[currentIndex] = temp;

            m_currentIndex = currentIndex++;

            yield return temp;
        }
    }
}


For those that might inquire, here's the source for FastRandom and SecureRandom.
Enumerate once

I'm not sure whether you intended to write this to be iterable only once. Is this as designed?

[TestMethod]
public void CodeReview()
{
    var bag = new ShuffleBag&lt;string&gt;(new[] { "a", "b", "c", "d" });

    var e1 = bag.ToList();  // randomized: "b", "a", "c", "d"
    var e2 = bag.ToList();  // last element: "d"
    var e3 = bag.ToList();  // last element: "d"
}


Collections interfaces

I would let the bag inherit IReadOnlyCollection&lt;T&gt; to provide eager access to the bag's size:

public int Count =&gt; m_values.Length;