lab_trees
Tempestuous Trees
|
A derived, templatized class for inorder traversal algorithms on trees. More...
#include <InorderTraversal.h>
Public Member Functions | |
InorderTraversal (typename BinaryTree< T >::Node *root) | |
Initializes a Inorder TreeTraversal of a tree, with the traversal storing the tree's root. More... | |
TreeTraversal< T >::Iterator | begin () |
Returns an iterator for the traversal starting at the root node. More... | |
TreeTraversal< T >::Iterator | end () |
Returns an iterator for the traversal pointing to the element one past the end of the traversal. More... | |
void | add (typename BinaryTree< T >::Node *&treeNode) |
Given a node in the tree, add the next appropriate nodes to the stack such that when popped, and inorder traversal is simulated. More... | |
BinaryTree< T >::Node * | pop () |
Removes and returns the current node in the traversal. More... | |
BinaryTree< T >::Node * | peek () const |
Returns the current node in the traversal or NULL if the stack is empty. More... | |
bool | empty () const |
Returns true if the traversal is empty. More... | |
Private Attributes | |
std::stack< typename BinaryTree< T >::Node * > | stack |
BinaryTree< T >::Node * | root |
A derived, templatized class for inorder traversal algorithms on trees.
Simulates an iterative traversal of a given tree using a stack and a given root node.
|
inline |
Initializes a Inorder TreeTraversal of a tree, with the traversal storing the tree's root.
Hint: See lab handout for guidance
root | The root node of the tree |
|
inlinevirtual |
Given a node in the tree, add the next appropriate nodes to the stack such that when popped, and inorder traversal is simulated.
Hint: See lab handout for guidance
treeNode | The subroot that determines what next nodes should be added to the traversal |
Implements TreeTraversal< T >.
|
inlinevirtual |
Returns an iterator for the traversal starting at the root node.
Important for sake of looping through an iterator's contents.
Implements TreeTraversal< T >.
|
inlinevirtual |
Returns true if the traversal is empty.
Implements TreeTraversal< T >.
|
inlinevirtual |
Returns an iterator for the traversal pointing to the element one past the end of the traversal.
Important for the sake of looping through an iterator's contents
Implements TreeTraversal< T >.
|
inlinevirtual |
Returns the current node in the traversal or NULL if the stack is empty.
Implements TreeTraversal< T >.
|
inlinevirtual |
Removes and returns the current node in the traversal.
Implements TreeTraversal< T >.