Пример #1
0
		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;
		}
Пример #2
0
		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);
			}
		}
Пример #3
0
		public STNode AddLast(STNode node) {
			Contract.Requires(node != null);
			Contract.Requires(node.Parent == null);
			return AddLastPrivate(node);
		}
Пример #4
0
		private STNode AddPrevIgnoringFirstChild(STNode node) {
			node.Parent = This.Parent;
			node.Next = This;
			node.Prev = Prev;
			Prev.Next = node;
			Prev = node;
			return node;
		}
Пример #5
0
		private STNode AddFirstPrivate(STNode node) {
			AddLastPrivate(node);
			FirstChild = node;
			return node;
		}
Пример #6
0
		public STNode AddNext(STNode node) {
			Contract.Requires(node != null);
			Contract.Requires(node.Parent == null);
			Contract.Requires(Parent != null);
			return This.Next.AddPrevIgnoringFirstChild(node);
		}
Пример #7
0
		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);
		}