예제 #1
0
 public RBBranch(T value, RBBranch <T> parent)
 {
     this.parent = parent;
     this.value  = value;
     red         = true;
     left        = new RBLeaf <T> (this);
     right       = new RBLeaf <T> (this);
 }
예제 #2
0
 void Insert(RBBranch <T> node)
 {
     root.Insert(node);
     node.InsertRepair();
     root = node;
     while (root.parent != null)
     {
         root = root.parent;
     }
 }
예제 #3
0
 void ReplaceNode(RBNode <T> child)
 {
     child.parent = parent;
     if (parent != null)
     {
         if (this == parent.left)
         {
             parent.left = child;
         }
         else
         {
             parent.right = child;
         }
     }
 }
예제 #4
0
        public void Remove(T value)
        {
            root.Remove(value);

            RBBranch <T> rootBranch = (RBBranch <T>)root;

            if (rootBranch.left.parent == null)
            {
                root = rootBranch.left;
            }
            else if (rootBranch.right.parent == null)
            {
                root = rootBranch.right;
            }
            while (root.parent != null)
            {
                root = root.parent;
            }
        }
예제 #5
0
 public RBTree()
 {
     root = new RBLeaf <T> ();
 }