예제 #1
0
        public LineSegment InsertAfter(LineSegment segment, int length, int delimiterLength)
        {
            TreeNode result = new TreeNode(length, delimiterLength);

            result.StartSpan = segment.StartSpan;
            RedBlackTree <TreeNode> .RedBlackTreeNode newNode = new RedBlackTree <TreeNode> .RedBlackTreeNode(result);

            RedBlackTree <TreeNode> .RedBlackTreeIterator iter = segment != null ? segment.Iter : null;
            if (iter == null)
            {
                tree.Root       = newNode;
                result.TreeNode = tree.Root;
                tree.Count      = 1;
                return(result);
            }

            if (iter.node.right == null)
            {
                tree.Insert(iter.node, newNode, false);
            }
            else
            {
                tree.Insert(iter.node.right.OuterLeft, newNode, true);
            }
            result.TreeNode = newNode;
            UpdateNode(newNode);
            OnLineChanged(new LineEventArgs(result));
            return(result);
        }
예제 #2
0
        RedBlackTree <TreeNode> .RedBlackTreeNode InsertAfter(RedBlackTree <TreeNode> .RedBlackTreeNode node, TreeNode nodeToInsert)
        {
            RedBlackTree <TreeNode> .RedBlackTreeNode newNode = new RedBlackTree <TreeNode> .RedBlackTreeNode(nodeToInsert);

            RedBlackTree <TreeNode> .RedBlackTreeIterator iter = new RedBlackTree <TreeNode> .RedBlackTreeIterator(node);

            if (iter.node.right == null)
            {
                tree.Insert(iter.node, newNode, false);
            }
            else
            {
                tree.Insert(iter.node.right.OuterLeft, newNode, true);
            }

            UpdateNode(newNode);
            return(newNode);
        }