コード例 #1
0
 protected bool RemoveNodeRecursively(NodePath path, NodeContainer currentNode)
 {
     currentNode = (currentNode != null ? currentNode : this);
     string key = path.Dequeue();
     if (currentNode.Nodes.ContainsKey(key))
     {
         if (path.Path.Count <= 0)
             return currentNode.Nodes.Remove(key);
         else
             RemoveNodeRecursively(path, currentNode.Nodes[key]);
     }
     return false;
 }
コード例 #2
0
 public Node GetNode(NodePath path)
 {
     string key = path.Dequeue();
     if (path.Path.Count > 0)
     {
         if (nodes.ContainsKey(key))
             return nodes[key].GetNode(path);
     }
     else
     {
         return (nodes[key] != null ? nodes[key] : null);
     }
     return null;
 }
コード例 #3
0
 protected void AddNodeRecursively(NodePath pathToGoal, Node node, NodeContainer mother)
 {
     mother = (mother != null ? mother : this);
     string key = pathToGoal.Dequeue();
     if (pathToGoal.Path.Count > 0)
     {
         if (!mother.Nodes.ContainsKey(key))
             mother.Nodes.Add(key, new Node(key));
         Node newNode = mother.Nodes[key];
         AddNodeRecursively(pathToGoal, node, newNode);
         return;
     }
     if (!mother.Nodes.ContainsKey(key))
         mother.Nodes.Add(key, node);
     else
         mother.Nodes[key] = node;
 }
コード例 #4
0
 public bool RemoveNode(NodePath path)
 {
     return RemoveNodeRecursively(path, null);
 }
コード例 #5
0
 public void AddNode(NodePath path, Node node)
 {
     AddNodeRecursively(path, node, null);
 }