public void AddFirst(AstNode child) { if (child == null) { return; } if (this.children == null) { this.children = child; return; } // Add my children to the end of the list. AstNode lastChild = child; while (lastChild.GetNext() != null) { lastChild = lastChild.GetNext(); } lastChild.SetNext(children); // Set the first. children = child; }
public void AddLast(AstNode child) { if (child == null) { return; } if (this.children == null) { this.children = child; return; } AstNode lastChild = this.children; while (lastChild.GetNext() != null) { lastChild = lastChild.GetNext(); } lastChild.SetNext(child); }