RTBST Traverser First Initialization - GNU libavl 2.0.3
Author: Ben Pfaff

10.6.1 Starting at the First Node |

To find the first (least) item in the tree, we just descend all the way to the left, as usual. In an RTBST, as in a BST, this involves checking for null pointers.

    398. <RTBST traverser first initializer 398> =
    void *
    rtbst_t_first (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_link[0] != NULL)
            trav->rtbst_node = trav->rtbst_node->rtbst_link[0];
          return trav->rtbst_node->rtbst_data;
        }
      else
        return NULL;
    }

This code is included in 397.