private static void InsertNodeAfter(SharpTreeNode pos, SharpTreeNode newNode) { // newNode might be the model root of a whole subtree, so go to the list root of that subtree: newNode = newNode.GetListRoot(); if (pos.right == null) { pos.right = newNode; newNode.listParent = pos; } else { // insert before pos.right's leftmost: pos = pos.right; while (pos.left != null) { pos = pos.left; } Debug.Assert(pos.left == null); pos.left = newNode; newNode.listParent = pos; } RebalanceUntilRoot(pos); }
static SharpTreeNode ConcatTrees(SharpTreeNode first, SharpTreeNode second) { SharpTreeNode tmp = first; while (tmp.right != null) { tmp = tmp.right; } InsertNodeAfter(tmp, second); return(tmp.GetListRoot()); }
public int IndexOf(object item) { SharpTreeNode node = item as SharpTreeNode; if (node != null && node.IsVisible && node.GetListRoot() == root) { if (includeRoot) { return(SharpTreeNode.GetVisibleIndexForNode(node)); } else { return(SharpTreeNode.GetVisibleIndexForNode(node) - 1); } } else { return(-1); } }
static void DumpTree(SharpTreeNode node) { node.GetListRoot().DumpTree(); }
static void InsertNodeAfter(SharpTreeNode pos, SharpTreeNode newNode) { // newNode might be the model root of a whole subtree, so go to the list root of that subtree: newNode = newNode.GetListRoot(); if (pos.right == null) { pos.right = newNode; newNode.listParent = pos; } else { // insert before pos.right's leftmost: pos = pos.right; while (pos.left != null) pos = pos.left; Debug.Assert(pos.left == null); pos.left = newNode; newNode.listParent = pos; } RebalanceUntilRoot(pos); }