/// <summary> /// Reconstruct connected node a,b,c and their childrens. /// 将相连的三个顶点和其子孙连进行重构 /// </summary> /// <returns>新的祖先,即<paramref name="b"/></returns> /// <remarks> /// after reconstruction: /// 重构以后的形状 /// b /// / \ /// a c /// / \ / \ /// t0 t1 t2 t3 /// </remarks> protected static BinaryTreeNode Connect34(BinaryTreeNode a, BinaryTreeNode b, BinaryTreeNode c, BinaryTreeNode t0, BinaryTreeNode t1, BinaryTreeNode t2, BinaryTreeNode t3, BinaryTreeNode top) { Contract.Requires <ArgumentNullException>(a != null); Contract.Requires <ArgumentNullException>(b != null); Contract.Requires <ArgumentNullException>(c != null); Contract.Ensures(a.LeftChild == t0); Contract.Ensures(a.RightChild == t1); Contract.Ensures(c.LeftChild == t2); Contract.Ensures(c.RightChild == t3); Contract.Ensures(b.LeftChild == a); Contract.Ensures(b.RightChild == c); Contract.EndContractBlock(); top.TransferParent(b); a.LeftChild = t0; a.RightChild = t1; a.SearchUp(true); c.LeftChild = t2; c.RightChild = t3; c.SearchUp(true); b.LeftChild = a; b.RightChild = c; b.SearchUp(); return(b); }