private void Visit(Node node, IVisitor v) { if (node == null) { return; } Visit(node.left, v); v.Action(node); Visit(node.right, v); }
/// <summary> /// Visit all nodes in the binary tree. /// </summary> /// <param name="visitor">Visitor</param> /// <param name="curNode">Current node</param> protected virtual void Visit(IVisitor visitor, MathParserTreeNode curNode) { if (curNode != null) { if (curNode.Left != null) Visit(visitor, curNode.Left); if (curNode.Right != null) Visit(visitor, curNode.Right); visitor.Action(curNode); } }
/// <summary> /// Visit all nodes in the binary tree. /// </summary> /// <param name="visitor">Visitor</param> /// <param name="curNode">Current node</param> protected virtual void Visit(IVisitor visitor, MathParserTreeNode curNode) { if (curNode != null) { if (curNode.Left != null) { Visit(visitor, curNode.Left); } if (curNode.Right != null) { Visit(visitor, curNode.Right); } visitor.Action(curNode); } }
public override void getVisitor(IVisitor v) { v.Action(this); }