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_;
}
|