Exemple #1
0
 /// <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();
 }
Exemple #2
0
 /// <summary>
 /// Initialize the variations for constructors.
 /// </summary>
 /// <param name="values">List of values to select variations from.</param>
 /// <param name="lowerIndex">The size of each variation set to return.</param>
 /// <param name="type">The type of variations 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);
     if (type == GenerateOption.WithoutRepetition)
     {
         List <int> myMap = new List <int>();
         int        index = 0;
         for (int i = 0; i < myValues.Count; ++i)
         {
             if (i >= myValues.Count - myLowerIndex)
             {
                 myMap.Add(index++);
             }
             else
             {
                 myMap.Add(Int32.MaxValue);
             }
         }
         myPermutations = new Permutations <int>(myMap);
     }
     else
     {
         ; // myPermutations isn't used.
     }
 }