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

To start from an item found in the tree, we use the same algorithm as rtbst_find().

398. <RTBST traverser search initializer 398> =
void *
rtbst_t_find (struct rtbst_traverser *trav, struct rtbst_table *tree,
              void *item)
{ struct rtbst_node *p; assert (trav != NULL && tree != NULL && item != NULL); trav->rtbst_table = tree; trav->rtbst_node = NULL; p = tree->rtbst_root; if (p == NULL) return NULL; for (;;)
    { int cmp = tree->rtbst_compare (item, p->rtbst_data, tree->rtbst_param); if (cmp == 0)
        { trav->rtbst_node = p; return p->rtbst_data; } if (cmp < 0)
        { p = p->rtbst_link[0]; if (p == NULL) return NULL; }
      else
        { if (p->rtbst_rtag == RTBST_THREAD) return NULL; p = p->rtbst_link[1]; } } }

This code is included in 395.