private IEnumerable <List <Champion> > GetChampionLists(List <Champion> src) { if (src.Count == 0) { yield return(new List <Champion>()); yield break; } Champion c = src[0]; src.RemoveAt(0); foreach (List <Champion> result in this.GetChampionLists(src)) { // Apply every version of c foreach (Delta delta in this.deltasToApply) { Champion clone = c.Clone(delta.Speed, delta.SpeedSets, delta.PerceptionSets); if (clone.EffectiveSpeed < clone.BaseSpeed) { continue; } result.Add(clone); yield return(result); result.Remove(clone); } } }
public static IEnumerable <Champion[]> ChampionRosetta(int count, Champion[] array) { Champion[] result = new Champion[count]; Stack <int> stack = new Stack <int>(count); stack.Push(0); while (stack.Count > 0) { int index = stack.Count - 1; int value = stack.Pop(); while (value < array.Length) { result[index++] = array[value++]; stack.Push(value); if (index != count) { continue; } yield return((Champion[])result.Clone()); // thanks to @xanatos //yield return result; break; } } }