| | | | | |

Inorder Iterator Incrementation

template < class N >
void BinaryTreeInorderIterator<N>::Increment()
// operator++, except ignores tombstones
{
  if (!Valid())              // do nothing to invalid iterator
    return;
  if (nav_.HasRightChild())  // slide down the left subtree of right child
  {
    nav_++;
    while (nav_.HasLeftChild())
      ++nav_;
  }
  else                      // back up to first ancestor not already visited
  {
    bool navWasRightChild;
    do
    {
      navWasRightChild = nav_.IsRightChild();
      --nav_;
    }
    while (navWasRightChild);
  }
}

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