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); }
public void AddNode(GPAbstractNode nodeFilho) { if (CanAddNode(nodeFilho)) { nodeFilho.nodePai = this; children.Add(nodeFilho); } }
public virtual GPAbstractNode Clone() { GPAbstractNode node = semantica.InstantiateEmpty(); for (int i = 0; i < children.Count; i++) { node.AddNode(children[i].Clone()); } return(node); }
public bool ContainsNode(GPAbstractNode nodeToCheck) { if (this == nodeToCheck) { return(true); } foreach (GPAbstractNode node in children) { if (node.ContainsNode(nodeToCheck)) { return(true); } } return(false); }
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)); }