We use p to search down the tree and keep track of p's parent with
q. We keep the invariant at the beginning of the loop here that
q->tavl_link[dir] == p. As the final step, we record the item deleted
and update the tree's item count.
312. <Step 1: Search TAVL tree for item to delete 312> =
if (tree->tavl_root == NULL)
return NULL;
p = (struct tavl_node *) &tree->tavl_root;
for (cmp = -1; cmp != 0;
cmp = tree->tavl_compare (item, p->tavl_data, tree->tavl_param))
{
dir = cmp > 0;
q = p;
if (p->tavl_tag[dir] == TAVL_THREAD)
return NULL;
p = p->tavl_link[dir];
}
item = p->tavl_data;
This code is included in 311 and 670.
8.5 Deletion
|
8.5 Deletion
|
8.5.2 Step 2: Delete
|