| | | | | |

Increment (structural)

Algorithm:

    Increment
    {
      do nothing on null iterator
      if node_ is right threaded
      {
        go where right thread points
      }
      else
      {
        go to right child
        slide left as far as possible
      }
    }

Code:

    void Increment ()
    {
      if (node_ == nullptr) return;
      if (node_->IsRightThreaded())
      {
        node_ = node_->rchild_;
        return;
      }
      node_ = node_->rchild_;
      while (node_ != nullptr && node_->HasLeftChild())
        node_ = node_->lchild_;
    }

| | Top of Page | 14. BST Iterators - 36 of 41