public static void Traverse(NTree <T> node, TreeVisitor <T> visitor) { visitor(node.data); foreach (NTree <T> kid in node.children) { Traverse(kid, visitor); } }
public static void Traverse(NTree <T> node, Action startAct, TreeVisitor <T> visitor, Action endAct) { startAct(); visitor(node.data); foreach (NTree <T> kid in node.children) { Traverse(kid, startAct, visitor, endAct); } endAct(); }
public NTree <T> Clone() { var tree = new NTree <T>(this.data); foreach (var child in this.children) { tree.AddChild(child); } return(tree); }
public static NTree <T> CreateTree <T>(NTree <T> tree, params T[] children) { var clone = tree.Clone(); foreach (var child in children) { clone.AddChild(child); } return(clone); }
public static NTree <T> CreateTree <T>(T root, params NTree <T>[] children) { var tree = new NTree <T>(root); foreach (var child in children) { tree.AddChild(child); } return(tree); }
public static NTree <T> CreateTree <T>(NTree <T> root, params NTree <T>[] children) { var clone = root.Clone(); foreach (var child in children) { clone.AddChild(child); } return(clone); }
public void AddChild(NTree <T> data) { children.AddFirst(data.Clone()); }