public IEnumerator <IList <T> > GetEnumerator() { var list = this.m_List; if (list.Count > 0) { foreach (IList <T> sequence in Permutable <T> .Permute(list, 0, list.Count - 1)) { yield return(sequence); } } }
static IEnumerable Permute <TElement>(IList <TElement> list, int depth, int count) { if (count == depth) { yield return(list); } else { for (var i = depth; i <= count; ++i) { Swap(list, depth, i); foreach (var sequence in Permutable <T> .Permute(list, 1 + depth, count)) { yield return(sequence); } Swap(list, depth, i); } } }