Exemplo n.º 1
0
 VoxelTree GetMinKey()
 {
     if (leftTree == null)
     {
         return(this);
     }
     else
     {
         return(leftTree.GetMinKey());
     }
 }
Exemplo n.º 2
0
    public bool Delete(int hashkey)
    {
        if (hashkey == key)
        {
            if ((leftTree != null) && (rightTree != null))
            {
                //we have left and right trees,
                //copy the right's minimum tree into this tree
                //delete from right tree
                VoxelTree target = rightTree.GetMinKey();
                voxel = target.voxel;
                key   = target.key;
                rightTree.Delete(key);
            }
            else if (parent.leftTree == this)
            {
                //point parent directly at child
                //depends on GC to remove this?
                parent.leftTree = (leftTree != null) ? leftTree : rightTree;
            }
            else if (parent.rightTree == this)
            {
                //point parent directly at child
                //depends on GC to remove this?
                parent.rightTree = (leftTree != null) ? leftTree : rightTree;
            }
            return(true);
        }

        if (hashkey < key)
        {
            if (leftTree == null)
            {
                return(false);
            }
            return(leftTree.Delete(hashkey));
        }
        else
        {
            if (rightTree == null)
            {
                return(false);
            }
            return(rightTree.Delete(hashkey));
        }
    }