/// <summary> /// Construct a enumerator with the parent object. /// </summary> /// <param name="source">The source Permutations object.</param> public Enumerator(Permutations <T> source) { myParent = source; myLexicographicalOrders = new int[source.myLexicographicOrders.Length]; source.myLexicographicOrders.CopyTo(myLexicographicalOrders, 0); Reset(); }
/// <summary> /// Initialize the combinations by settings a copy of the values from the /// </summary> /// <param name="values">List of values to select combinations from.</param> /// <param name="lowerIndex">The size of each combination set to return.</param> /// <param name="type">The type of Combinations set to generate.</param> private void Initialize(IList <T> values, int lowerIndex, GenerateOption type) { myMetaCollectionType = type; myLowerIndex = lowerIndex; myValues = new List <T>(); myValues.AddRange(values); List <bool> myMap = new List <bool>(); if (type == GenerateOption.WithoutRepetition) { for (int i = 0; i < myValues.Count; ++i) { if (i >= myValues.Count - myLowerIndex) { myMap.Add(false); } else { myMap.Add(true); } } } else { for (int i = 0; i < values.Count - 1; ++i) { myMap.Add(true); } for (int i = 0; i < myLowerIndex; ++i) { myMap.Add(false); } } myPermutations = new Permutations <bool>(myMap); }