lab_trees
Tempestuous Trees
TreeTraversal< T > Class Template Referenceabstract

Pure virtual class for traversal algorithms on trees. More...

#include <TreeTraversal.h>

Inheritance diagram for TreeTraversal< T >:
[legend]

Classes

class  Iterator
 A forward iterator class through an TreeTravesal, derived from the std iterator class. More...
 

Public Member Functions

virtual Iterator begin ()=0
 Public pure virtual begin() function. More...
 
virtual Iterator end ()=0
 Public pure virtual end() function. More...
 
virtual void add (typename BinaryTree< T >::Node *&treeNode)=0
 Public pure virtual add() function. More...
 
virtual BinaryTree< T >::Node * pop ()=0
 Public pure virtual pop() function remove the current Node to be processed. More...
 
virtual BinaryTree< T >::Node * peek () const =0
 Public pure virtual peek() function. More...
 
virtual bool empty () const =0
 Public pure virtual empty() function. More...
 

Detailed Description

template<typename T>
class TreeTraversal< T >

Pure virtual class for traversal algorithms on trees.

Each derived class must not modify the tree itself

A derived class provides a traversal by returning instances of TreeTraversal::Iterator.

Member Function Documentation

◆ add()

template<typename T >
virtual void TreeTraversal< T >::add ( typename BinaryTree< T >::Node *&  treeNode)
pure virtual

Public pure virtual add() function.

Parameters
treeNodeThe current Node to be processed

Implemented in InorderTraversal< T >, and PreorderTraversal< T >.

◆ begin()

template<typename T >
virtual Iterator TreeTraversal< T >::begin ( )
pure virtual

Public pure virtual begin() function.

Returns
an Iterator points to the first element in the Traversal

Implemented in InorderTraversal< T >, and PreorderTraversal< T >.

◆ empty()

template<typename T >
virtual bool TreeTraversal< T >::empty ( ) const
pure virtual

Public pure virtual empty() function.

Returns
if the stack is empty or not

Implemented in InorderTraversal< T >, and PreorderTraversal< T >.

◆ end()

template<typename T >
virtual Iterator TreeTraversal< T >::end ( )
pure virtual

Public pure virtual end() function.

Returns
an Iterator one after the last element in the Traversal

Implemented in InorderTraversal< T >, and PreorderTraversal< T >.

◆ peek()

template<typename T >
virtual BinaryTree<T>::Node* TreeTraversal< T >::peek ( ) const
pure virtual

Public pure virtual peek() function.

Returns
a pointer to the Node on top of the stack

Implemented in InorderTraversal< T >, and PreorderTraversal< T >.

◆ pop()

template<typename T >
virtual BinaryTree<T>::Node* TreeTraversal< T >::pop ( )
pure virtual

Public pure virtual pop() function remove the current Node to be processed.

Returns
a pointer to the removed Node

Implemented in InorderTraversal< T >, and PreorderTraversal< T >.


The documentation for this class was generated from the following file: