#include <bintree.h>
Public Member Functions | |
CompleteBinaryTree (void) | |
CompleteBinaryTree (const CompleteBinaryTree< T > &bt) | |
virtual | ~CompleteBinaryTree () |
virtual bool | isEmpty (void) const |
virtual unsigned int | size (void) const |
virtual AbstractIterator< T > * | iteratorPtr (void) const |
BinTreeBreadthFirstIterator< T > | breadthFirstIterator (void) const |
virtual void | pushBack (const T element) |
virtual void | popBack (void) |
virtual void | purge (void) |
virtual T & | first (void) throw (EmptyCollectionException) |
virtual const T & | first (void) const throw (EmptyCollectionException) |
virtual T & | last (void) throw (EmptyCollectionException) |
virtual const T & | last (void) const throw (EmptyCollectionException) |
void | operator= (const CompleteBinaryTree< T > &tree) |
CompleteBinaryTree
object is a binary tree node structure encapsulated in the class BinTreeNode
.It is good to be aware that this implementation of a complete binary tree may not be the best for your application. For example, if your tree is going to have a fixed number of nodes, it might better to use an array instead of this class!
seal::CompleteBinaryTree< T >::CompleteBinaryTree | ( | void | ) | [inline] |
Default constructor. Creates an empty tree. The user will have to use the function CompleteBinaryTree::pushBack
to construct the tree.
seal::CompleteBinaryTree< T >::CompleteBinaryTree | ( | const CompleteBinaryTree< T > & | bt | ) | [inline] |
Copy constructor. The old and the new object will share the same data after the construction of the new object.
seal::CompleteBinaryTree< T >::~CompleteBinaryTree | ( | void | ) | [inline, virtual] |
Destructor.
virtual bool seal::CompleteBinaryTree< T >::isEmpty | ( | void | ) | const [inline, virtual] |
Returns true if the tree is empty; False otherwise.
Implements seal::Collection< T >.
virtual unsigned int seal::CompleteBinaryTree< T >::size | ( | void | ) | const [inline, virtual] |
Returns the number of nodes in the tree.
Implements seal::Collection< T >.
virtual AbstractIterator<T>* seal::CompleteBinaryTree< T >::iteratorPtr | ( | void | ) | const [inline, virtual] |
Returns a pointer to a breadth first iterator of the tree. The client of this function should be responsible to delete the returned iterator object using delete
.
Implements seal::Collection< T >.
BinTreeBreadthFirstIterator<T> seal::CompleteBinaryTree< T >::breadthFirstIterator | ( | void | ) | const [inline] |
Returns a breadth first iterator of the tree.
void seal::CompleteBinaryTree< T >::pushBack | ( | const T | element | ) | [inline, virtual] |
Adds an element to the tree while retaining its completeness property.
void seal::CompleteBinaryTree< T >::popBack | ( | void | ) | [inline, virtual] |
Removes the last element of tree, hence retaining the completeness property.
void seal::CompleteBinaryTree< T >::purge | ( | void | ) | [inline, virtual] |
Removes all the nodes from the tree.
Implements seal::Collection< T >.
T & seal::CompleteBinaryTree< T >::first | ( | void | ) | throw (EmptyCollectionException) [inline, virtual] |
Returns a reference to the first/root element in the tree. Throws an seal::EmptyCollectionException
if the tree is empty.
Implements seal::Collection< T >.
const T & seal::CompleteBinaryTree< T >::first | ( | void | ) | const throw (EmptyCollectionException) [inline, virtual] |
Returns a constant reference to the first/root element in the tree. Throws an seal::EmptyCollectionException
if the tree is empty.
Implements seal::Collection< T >.
T & seal::CompleteBinaryTree< T >::last | ( | void | ) | throw (EmptyCollectionException) [inline, virtual] |
Returns a reference to the last element in the tree. Throws an seal::EmptyCollectionException
if the tree is empty.
Implements seal::Collection< T >.
const T & seal::CompleteBinaryTree< T >::last | ( | void | ) | const throw (EmptyCollectionException) [inline, virtual] |
Returns a constant reference to the last element in the tree. Throws an seal::EmptyCollectionException
if the tree is empty.
Implements seal::Collection< T >.
void seal::CompleteBinaryTree< T >::operator= | ( | const CompleteBinaryTree< T > & | tree | ) | [inline] |
Assignment operator. The LHS object and the RHS object will both share the data of the RHS object after the assignment operation.