7.8.4 Starting at a Found Node [ToC] [Index]     [Skip Back] [Skip Fwd]     [Prev] [Up] [Next]

The code for this function is derived with few changes from <TBST search function 255>.

274. <TBST traverser search initializer 274> =
void *
tbst_t_find (struct tbst_traverser *trav, struct tbst_table *tree, void *item)
{ struct tbst_node *p; assert (trav != NULL && tree != NULL && item != NULL); trav->tbst_table = tree; trav->tbst_node = NULL; p = tree->tbst_root; if (p == NULL) return NULL; for (;;)
    { int cmp, dir; cmp = tree->tbst_compare (item, p->tbst_data, tree->tbst_param); if (cmp == 0)
        { trav->tbst_node = p; return p->tbst_data; } dir = cmp > 0; if (p->tbst_tag[dir] == TBST_CHILD) p = p->tbst_link[dir]; else
        return NULL; } }

This code is included in 270.