Пример #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     += 1u;
                return(this.root);
            }
            List <RBTree.Node> list = RBTree.alloc_path();
            int in_tree_cmp         = this.find_key <T>(key, list);

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

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