protected List <PatternNodePPA> Compute(PatternNodePPA node, IPermutationsCollection avoidedPermutations, int depthComputed, ResultPPA result) { List <PatternNodePPA> nodes = new List <PatternNodePPA>(); List <PatternNodePPA> newNodes = new List <PatternNodePPA>(); IPermutationDictionary <ExtensionMap> extensionMaps = new PermutationDictionary <ExtensionMap>(); nodes.Add(node); for (int i = 0; i < depthComputed; i++) { extensionMaps = ExtractExtensionMaps(nodes); foreach (var nodeProcessed in nodes) { newNodes.AddRange(nodeProcessed.ComputeChildren(extensionMaps, avoidedPermutations)); } result.ProcessNodes(newNodes); nodes = newNodes; newNodes = new List <PatternNodePPA>(); } return(nodes); }
protected void ComputeStepDefault(PatternNodePPA node, ResultPPA result) { PatternNodePPA parent = node.Parent; IPermutationDictionary <ExtensionMap> extensionMaps; parent.TryGetExtensionMapsDescendants(out extensionMaps); List <PatternNodePPA>[] descendants; parent.TryGetDescendants(out descendants); List <PatternNodePPA> nodes = descendants[node.PositionPrecedingLetters(node.Permutation.Length - 1)]; IPermutationDictionary <ExtensionMap> newExtensionMaps; List <PatternNodePPA>[] newDescendants = new List <PatternNodePPA> [node.Permutation.Length + 1]; List <PatternNodePPA> newNodes; List <PatternNodePPA> allNodes = new List <PatternNodePPA>(); for (int i = 0; i < newDescendants.Length; i++) { newDescendants[i] = new List <PatternNodePPA>(); } foreach (var nodeProcessed in nodes) { newNodes = nodeProcessed.ComputeChildren(extensionMaps, avoidedPermutations); allNodes.AddRange(newNodes); AddDescendants(newDescendants, newNodes, parent.DescendantsDepthFromNode, node.Permutation.Length); } result.ProcessNodes(allNodes); newExtensionMaps = ExtractExtensionMaps(allNodes); node.SetDescendants(newDescendants, parent.DescendantsDepthFromNode); node.SetExtensionMapsDescendants(newExtensionMaps); }