コード例 #1
0
 public bool TransferNode(GPAbstractNode oldNode, GPAbstractNode newNode, bool mirror = true)
 {
     if (newNode.ContainsNode(this))
     {
         return(false);
     }
     if (!children.Contains(oldNode))
     {
         return(false);
     }
     for (int i = 0; i < children.Count; i++)
     {
         if (children[i] == oldNode)
         {
             children[i] = newNode;
             if (mirror && newNode.nodePai != null)
             {
                 newNode.nodePai.TransferNode(newNode, oldNode, false);
             }
             else
             {
                 oldNode.nodePai = newNode.nodePai;
                 newNode.nodePai = this;
             }
         }
     }
     return(true);
 }
コード例 #2
0
 public void AddNode(GPAbstractNode nodeFilho)
 {
     if (CanAddNode(nodeFilho))
     {
         nodeFilho.nodePai = this;
         children.Add(nodeFilho);
     }
 }
コード例 #3
0
        public virtual GPAbstractNode Clone()
        {
            GPAbstractNode node = semantica.InstantiateEmpty();

            for (int i = 0; i < children.Count; i++)
            {
                node.AddNode(children[i].Clone());
            }
            return(node);
        }
コード例 #4
0
 public bool ContainsNode(GPAbstractNode nodeToCheck)
 {
     if (this == nodeToCheck)
     {
         return(true);
     }
     foreach (GPAbstractNode node in children)
     {
         if (node.ContainsNode(nodeToCheck))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #5
0
        public virtual bool CanAddNode(GPAbstractNode nodeFilho)
        {
            if (nodeFilho.nodePai != null)
            {
                return(false);
            }
            if (nodeFilho.ContainsNode(this))
            {
                return(false);
            }
            if (semantica == null)
            {
                return(false);
            }
            int count = children.Count;

            return(semantica.CanAddNode(count, nodeFilho));
        }