10.6.2 Starting at the Last Node |
|
To start at the last (greatest) item in the tree, we descend all the way
to the right. In an RTBST, as in a TBST, this involves checking for
thread links.
397. <RTBST traverser last initializer 397> =
void *
rtbst_t_last (struct rtbst_traverser *trav, struct rtbst_table *tree)
{
assert (tree != NULL && trav != NULL);
trav->rtbst_table = tree;
trav->rtbst_node = tree->rtbst_root;
if (trav->rtbst_node != NULL)
{
while (trav->rtbst_node->rtbst_rtag == RTBST_CHILD)
trav->rtbst_node = trav->rtbst_node->rtbst_link[1];
return trav->rtbst_node->rtbst_data;
}
else
return NULL;
}
This code is included in 395.
10.6.1 Starting at the First Node
|
10.6 Traversal
|
10.6.3 Starting at a Found Node
|