/* Parent Parent * |- |+ * B A * -/ \ / \+ * A BL -> AL B * / \- +/ \ * AL C C BR * * - marks connections that are dettached * + marks connections that are created */ private AvlTreeNode <T> _rotateRight(AvlTreeNode <T> b) { AvlTreeNode <T> a = b.Left; AvlTreeNode <T> parent = b.Parent; // may be null if B was root AvlTreeNode <T> c = a.Right; // may be null var direction = b.Direction; Debug.Assert(a != null); // a.Left remains so no need to change this // b.Right remains so no need to change this _dettachFromParent(b); // b from parent _dettachFromParent(a); // a from b _dettachFromParent(c); // c from a _attachToParentEdge(c, b.EdgeLeft()); _attachToParentEdge(b, a.EdgeRight()); _attachToParentEdge(a, parent.EdgeTo(direction)); _recalc(b); _recalc(a); return(a); }
public static AvlTreeEdge <T> EdgeSelf <T>(this AvlTreeNode <T> source) { return(source.EdgeTo(AvlTreeNodeDirection.None)); }
public static AvlTreeEdge <T> EdgeParent <T>(this AvlTreeNode <T> source) { return(source.EdgeTo(AvlTreeNodeDirection.Parent)); }