Example #1
0
 public Enumerator(Permutations <T> source)
 {
     _myParent = source;
     _myLexicographicalOrders = new int[source._myLexicographicOrders.Length];
     source._myLexicographicOrders.CopyTo(_myLexicographicalOrders, 0);
     Reset();
 }
Example #2
0
        private void Initialize(ICollection <T> values, int lowerIndex, GenerateOption type)
        {
            _myMetaCollectionType = type;
            LowerIndex            = lowerIndex;
            _myValues             = new List <T>();
            _myValues.AddRange(values);
            var myMap = new List <bool>();

            switch (type)
            {
            case GenerateOption.WithoutRepetition:
            {
                myMap.AddRange(_myValues.Select((t, i) => i < _myValues.Count - LowerIndex));
                break;
            }

            default:
            {
                for (var i = 0; i < values.Count - 1; ++i)
                {
                    myMap.Add(true);
                }

                for (var i = 0; i < LowerIndex; ++i)
                {
                    myMap.Add(false);
                }

                break;
            }
            }

            _myPermutations = new Permutations <bool>(myMap);
        }