示例#1
0
        private IPermutationsCollection CreatePermutationsUnChecked(Permutation permutation, ExtensionMap extensionMap)
        {
            PermutationCollection permutationCollection = new PermutationCollection();

            foreach (var position in extensionMap.Ctz())
            {
                permutationCollection.Add(permutation.InsertPosition(position));
            }

            return(permutationCollection);
        }
        protected List <PermutationContainerPPA> ComputeSuccessors(IPermutationDictionary <ExtensionMap> collection,
                                                                   IPermutationsCollection avoidedPermutations,
                                                                   bool checkAvoidedPermutations)
        {
            Permutation  newPermutation;
            PatternBasic newPermutationPositions;
            ExtensionMap newExtensionMap;
            int          newMinimumLettersConsidered;
            List <PermutationContainerPPA> containers = new List <PermutationContainerPPA>();
            PermutationContainerPPA        permutationContainerPPA;

            int maximumLettersConsidered = Math.Min(lengthLongestPermutationAvoided, Permutation.Length + 1);

            foreach (var position in extensionMap.Ctz())
            {
                newPermutation = Permutation.InsertPosition(position);

                if (checkAvoidedPermutations && avoidedPermutations.Contains(newPermutation))
                {
                    continue;
                }
                newPermutationPositions = PermutationPositions.InsertLetter(position);
                newPermutationPositions = CorrectPositionsTop(newPermutationPositions);

                newMinimumLettersConsidered = minimumLettersBeChecked.
                                              GetMinimumLettersConsidered(collection, newPermutation,
                                                                          newPermutationPositions, maximumLettersConsidered);

                newExtensionMap = exMapComputationUnsorted.Compute(collection, newPermutation,
                                                                   newPermutationPositions, newMinimumLettersConsidered);

                if (checkAvoidedPermutations)
                {
                    CorrectExtensionMap(newPermutation, newExtensionMap, avoidedPermutations);
                }


                permutationContainerPPA = new PermutationContainerPPA(newPermutation, newPermutationPositions,
                                                                      minimumLettersBeChecked, exMapComputationUnsorted,
                                                                      newExtensionMap, lengthLongestPermutationAvoided,
                                                                      newMinimumLettersConsidered);

                containers.Add(permutationContainerPPA);
            }

            return(containers);
        }
示例#3
0
        private IPermutationsCollection CreatePermutationsChecked(Permutation permutation, ExtensionMap extensionMap,
                                                                  IPermutationsCollection avoidedPermutations)
        {
            PermutationCollection permutationCollection = new PermutationCollection();
            Permutation           newPermutation;

            foreach (var position in extensionMap.Ctz())
            {
                newPermutation = permutation.InsertPosition(position);
                if (!avoidedPermutations.Contains(newPermutation))
                {
                    permutationCollection.Add(newPermutation);
                }
            }

            return(permutationCollection);
        }