/// <summary> /// Perform a operation over all tree nodes in the /// specified order. The operation is specified /// through a visitor object. /// </summary> public void WalkTree(TreeNode nodeFrom, ITreeNodeVisitor visitor) { visitor.Visit(nodeFrom); foreach (TreeNode child in nodeFrom.Children) { WalkTree(child, visitor); } }
public override void Accept(ITreeNodeVisitor v) { v.Visit(this); foreach (var c in Children) { c.Accept(v); } }
/// <summary> /// Applies a visitor to each ancestor /// </summary> /// <param name="visitor"> /// The visitor. /// </param> public void Climb(ITreeNodeVisitor <T> visitor) { if (!visitor.Completed) { visitor.Visit(this); } if (!visitor.Completed && this.Parent != null) { Parent.Climb(visitor); } }
/// <summary> /// Applies a visitor to each node in a traversal. /// </summary> /// <param name="visitor"> /// The action. /// </param> public void Traverse(ITreeNodeVisitor <T> visitor) { if (!visitor.Completed) { visitor.Visit(this); } foreach (var child in this._children) { child.Traverse(visitor); if (visitor.Completed) { break; } } }
/// <summary> /// Perform a operation over all tree nodes in the /// specified order. The operation is specified /// through a visitor object. /// </summary> public void WalkTree(TreeNode nodeFrom, ITreeNodeVisitor visitor) { visitor.Visit(nodeFrom); foreach(TreeNode child in nodeFrom.Children) WalkTree(child, visitor); }
public void Accept(ITreeNodeVisitor visitor) { visitor.Visit(this); }
public override void Accept(ITreeNodeVisitor visitor) { visitor.Visit(this); }