3.3.1 Shuffles_FisherYates: Fisher–Yates shuffle
Parent: 3.3 Framework.Item · Guide map
Shuffles_FisherYates.Shuffle<T> shuffles a List<T> in place. It does not return a new list.
The in-place swap method is related to Richard Durstenfeld’s “Algorithm 235: Random permutation” (1964); this implementation traverses forward rather than backward. The Fisher–Yates name also honors the earlier procedure described in Fisher and Yates’s 1938 book. See research and provenance for the distinction.
using System.Collections.Generic;
using RandEXom.Framework.Item;
var cards = new List<string> { "red", "blue", "green" };
var shuffle = new Shuffles_FisherYates(seed: 42);
shuffle.Shuffle(cards);
Make a copy first if you need to preserve the original order.
← Previous: 3.3 Framework.Item · Parent: 3.3 Framework.Item · Next: 3.3.2 GachaR