示例#1
0
        private void ResolveState(State state, Tree.Embedding[] embeddings, Dictionary <State, List <Tree.Node> > mapping, Dictionary <State, Tree.Node> ret)
        {
            List <Tree.Node> instances;

            Tree.Node node = Tree.Node.Create(state);

            if (mapping.TryGetValue(state, out instances))
            {
                // Otherwise, merge all the embeddings into the equation
                instances.Sort(SortDeepestFirst);

                foreach (Tree.Node instance in instances)
                {
                    Tree.NodePath path = instance.Path;

                    if (path.Count == 0)
                    {
                        node = instance;
                        break;
                    }
                    else
                    {
                        node.Replace(path, instance);
                    }
                }
            }

            ret[state] = node;
        }
示例#2
0
 private int SortDeepestFirst(Tree.Node a, Tree.Node b)
 {
     if (a.Path.Count == 0)
     {
         return(1);
     }
     else if (b.Path.Count == 0)
     {
         return(-1);
     }
     else
     {
         return(b.Path.Peek().CompareTo(a.Path.Peek()));
     }
 }