private STNode AddLastPrivate(STNode node) { var second = FirstChild; if (second == null) { node.Parent = This; node.Next = node; node.Prev = node; FirstChild = node; } else { second.AddPrevIgnoringFirstChild(node); } return node; }
private static void ToStringPrivate( STNode node, int depth, StringBuilder builder) { if (node == null) { return; } for (int i = 0; i < depth; i++) { builder.Append(" "); } builder.AppendLine(node.Value.ToString()); foreach (var child in node.Children) { ToStringPrivate(child, depth + 1, builder); } }
public STNode AddLast(STNode node) { Contract.Requires(node != null); Contract.Requires(node.Parent == null); return AddLastPrivate(node); }
private STNode AddPrevIgnoringFirstChild(STNode node) { node.Parent = This.Parent; node.Next = This; node.Prev = Prev; Prev.Next = node; Prev = node; return node; }
private STNode AddFirstPrivate(STNode node) { AddLastPrivate(node); FirstChild = node; return node; }
public STNode AddNext(STNode node) { Contract.Requires(node != null); Contract.Requires(node.Parent == null); Contract.Requires(Parent != null); return This.Next.AddPrevIgnoringFirstChild(node); }
public STNode AddPrev(STNode node) { Contract.Requires(node != null); Contract.Requires(node.Parent == null); Contract.Requires(Parent != null); if (Parent.FirstChild == This) { Parent.FirstChild = node; } return AddPrevIgnoringFirstChild(node); }