seal::CompleteBinaryTree< T > Class Template Reference

#include <bintree.h>

Inheritance diagram for seal::CompleteBinaryTree< T >:

seal::Collection< T >

List of all members.

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)


Detailed Description

template<typename T>
class seal::CompleteBinaryTree< T >

This class encapsulates a complete binary tree. A user can add and remove elements from this tree while keeping the completeness property intact. Each node in a 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!


Constructor & Destructor Documentation

template<typename T>
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.

template<typename T>
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.

template<typename T>
seal::CompleteBinaryTree< T >::~CompleteBinaryTree ( void   )  [inline, virtual]

Destructor.


Member Function Documentation

template<typename T>
virtual bool seal::CompleteBinaryTree< T >::isEmpty ( void   )  const [inline, virtual]

Returns true if the tree is empty; False otherwise.

Implements seal::Collection< T >.

template<typename T>
virtual unsigned int seal::CompleteBinaryTree< T >::size ( void   )  const [inline, virtual]

Returns the number of nodes in the tree.

Implements seal::Collection< T >.

template<typename 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 >.

template<typename T>
BinTreeBreadthFirstIterator<T> seal::CompleteBinaryTree< T >::breadthFirstIterator ( void   )  const [inline]

Returns a breadth first iterator of the tree.

template<typename T>
void seal::CompleteBinaryTree< T >::pushBack ( const T  element  )  [inline, virtual]

Adds an element to the tree while retaining its completeness property.

template<typename T>
void seal::CompleteBinaryTree< T >::popBack ( void   )  [inline, virtual]

Removes the last element of tree, hence retaining the completeness property.

template<typename T>
void seal::CompleteBinaryTree< T >::purge ( void   )  [inline, virtual]

Removes all the nodes from the tree.

Implements seal::Collection< T >.

template<typename 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 >.

template<typename 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 >.

template<typename 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 >.

template<typename 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 >.

template<typename 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.


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

Generated on Sat May 16 21:35:20 2009 for SEAL by  doxygen 1.5.5