Implementing class BinaryTreeNavigator
template < typename T >
bool BinaryTreeNavigator<T>::HasParent () const
{
if (currNode_ != 0 && currNode_ -> parent_ != 0)
return 1;
return 0;
}
template < typename T >
bool BinaryTreeNavigator<T>::HasLeftChild () const
{
if (currNode_ != 0 && currNode_ -> lchild_ != 0)
return 1;
return 0;
}
template < typename T >
bool BinaryTreeNavigator<T>::IsLeftChild () const
{
if (currNode_ != 0 && currNode_ -> parent_ != 0 && currNode_ == currNode_ -> parent_ -> lchild_)
return 1;
return 0;
}
template < typename T >
bool BinaryTreeNavigator<T>::Valid() const
{
return currNode_ != 0;
}
template < typename T >
T& BinaryTreeNavigator<T>::Retrieve()
{
if (currNode_ == 0)
{
// error
}
return (currNode_->value);
}
template < typename T >
BinaryTreeNavigator<T> & BinaryTreeNavigator<T>::operator ++()
{
if (currNode_ != 0)
{
currNode_ = currNode_ -> lchild_;
}
return *this;
}
template < typename T >
BinaryTreeNavigator<T> & BinaryTreeNavigator<T>::operator ++(int)
{
if (currNode_ != 0)
{
currNode_ = currNode_ -> rchild_;
}
return *this;
}
template < typename T >
BinaryTreeNavigator<T> & BinaryTreeNavigator<T>::operator --()
{
if (currNode_ != 0)
{
currNode_ = currNode_ -> parent_;
}
return *this;
}