Exemple #1
0
        public RBTree.Node Intern <T>(T key, RBTree.Node new_node)
        {
            if (this.root == null)
            {
                if (new_node == null)
                {
                    new_node = ((RBTree.INodeHelper <T>) this.hlp).CreateNode(key);
                }
                this.root         = new_node;
                this.root.IsBlack = true;
                this.version      = this.version + 1U;
                return(this.root);
            }
            List <RBTree.Node> path = RBTree.alloc_path();
            int key1 = this.find_key <T>(key, path);

            RBTree.Node node = path[path.Count - 1];
            if (node == null)
            {
                if (new_node == null)
                {
                    new_node = ((RBTree.INodeHelper <T>) this.hlp).CreateNode(key);
                }
                node = this.do_insert(key1, new_node, path);
            }
            RBTree.release_path(path);
            return(node);
        }
Exemple #2
0
        public RBTree.Node Remove <T>(T key)
        {
            if (this.root == null)
            {
                return((RBTree.Node)null);
            }
            List <RBTree.Node> path = RBTree.alloc_path();
            int key1 = this.find_key <T>(key, path);

            RBTree.Node node = (RBTree.Node)null;
            if (key1 == 0)
            {
                node = this.do_remove(path);
            }
            RBTree.release_path(path);
            return(node);
        }