// Token: 0x060035C4 RID: 13764 RVA: 0x000F44EC File Offset: 0x000F26EC
        internal void InsertAtNode(SplayTreeNode location, bool insertBefore)
        {
            Invariant.Assert(this.ParentNode == null, "Can't insert child node!");
            Invariant.Assert(this.LeftChildNode == null, "Can't insert node with left children!");
            Invariant.Assert(this.RightChildNode == null, "Can't insert node with right children!");
            SplayTreeNode splayTreeNode = insertBefore ? location.GetPreviousNode() : location;
            SplayTreeNode rightSubTree;
            SplayTreeNode parentNode;

            if (splayTreeNode != null)
            {
                rightSubTree = splayTreeNode.Split();
                parentNode   = splayTreeNode.ParentNode;
            }
            else
            {
                rightSubTree = location;
                location.Splay();
                Invariant.Assert(location.Role == SplayTreeNodeRole.LocalRoot, "location should be local root!");
                parentNode = location.ParentNode;
            }
            SplayTreeNode.Join(this, splayTreeNode, rightSubTree);
            this.ParentNode = parentNode;
            if (parentNode != null)
            {
                parentNode.ContainedNode = this;
            }
        }
        // Token: 0x060035C5 RID: 13765 RVA: 0x000F4590 File Offset: 0x000F2790
        internal void Remove()
        {
            this.Splay();
            Invariant.Assert(this.Role == SplayTreeNodeRole.LocalRoot);
            SplayTreeNode parentNode     = this.ParentNode;
            SplayTreeNode leftChildNode  = this.LeftChildNode;
            SplayTreeNode rightChildNode = this.RightChildNode;

            if (leftChildNode != null)
            {
                leftChildNode.ParentNode = null;
            }
            if (rightChildNode != null)
            {
                rightChildNode.ParentNode = null;
            }
            SplayTreeNode splayTreeNode = SplayTreeNode.Join(leftChildNode, rightChildNode);

            if (parentNode != null)
            {
                parentNode.ContainedNode = splayTreeNode;
            }
            if (splayTreeNode != null)
            {
                splayTreeNode.ParentNode = parentNode;
            }
            this.ParentNode     = null;
            this.LeftChildNode  = null;
            this.RightChildNode = null;
        }
Beispiel #3
0
        // Token: 0x06003DB0 RID: 15792 RVA: 0x0011C904 File Offset: 0x0011AB04
        internal static void Remove(TextTreeTextBlock firstNode, TextTreeTextBlock lastNode)
        {
            SplayTreeNode previousNode = firstNode.GetPreviousNode();
            SplayTreeNode splayTreeNode;

            if (previousNode != null)
            {
                previousNode.Split();
                splayTreeNode           = previousNode.ParentNode;
                previousNode.ParentNode = null;
            }
            else
            {
                splayTreeNode = firstNode.GetContainingNode();
            }
            SplayTreeNode rightSubTree   = lastNode.Split();
            SplayTreeNode splayTreeNode2 = SplayTreeNode.Join(previousNode, rightSubTree);

            if (splayTreeNode != null)
            {
                splayTreeNode.ContainedNode = splayTreeNode2;
            }
            if (splayTreeNode2 != null)
            {
                splayTreeNode2.ParentNode = splayTreeNode;
            }
        }
Beispiel #4
0
        // Removes a run of nodes from a tree.
        internal static void Remove(TextTreeTextBlock firstNode, TextTreeTextBlock lastNode)
        {
            SplayTreeNode leftTree;
            SplayTreeNode rightTree;
            SplayTreeNode rootNode;
            SplayTreeNode containerNode;

            //
            // Break the tree into three subtrees.
            //

            leftTree = firstNode.GetPreviousNode();
            if (leftTree != null)
            {
                // Splitting moves leftTree to local root.
                leftTree.Split();
                containerNode       = leftTree.ParentNode;
                leftTree.ParentNode = null; // We'll fixup leftTree.ParentNode.ContainedNode below.
                // Join requires that leftTree has a null ParentNode.
            }
            else
            {
                // There are no preceeding nodes.
                containerNode = firstNode.GetContainingNode();
            }

            rightTree = lastNode.Split();

            //
            // Recombine the two outer trees.
            //
            rootNode = SplayTreeNode.Join(leftTree, rightTree);

            if (containerNode != null)
            {
                containerNode.ContainedNode = rootNode;
            }
            if (rootNode != null)
            {
                rootNode.ParentNode = containerNode;
            }
        }