vdk 2.4.0
Public Member Functions | List of all members
VDKBtree< T > Class Template Reference

provides a templatized binary tree data structure More...

#include <vdkbtrees.h>

Inheritance diagram for VDKBtree< T >:
AbstractRedBlackTree< T, RedBlackNode< T > > AbstractBinaryTree< T, RedBlackNode< T > >

Public Member Functions

 VDKBtree ()
 
- Public Member Functions inherited from AbstractBinaryTree< T, RedBlackNode< T > >
 AbstractBinaryTree (AbstractBinaryTree< T, RedBlackNode< T > > &)
 
AbstractBinaryTree< T,
RedBlackNode< T > > & 
operator= (AbstractBinaryTree< T, RedBlackNode< T > > &)
 
virtual void add (T &)
 
virtual void unlink (T &)
 
virtual T * find (T &q)
 
virtual int IsEmpty ()
 
virtual int CheckTreeProperties ()
 
unsigned int size ()
 

Detailed Description

template<class T>
class VDKBtree< T >

provides a templatized binary tree data structure

Description
VDKBtree<T> class has a value semantic, all objects are copied from original values. VDKBtree<T> class implements red/black balanced trees. All managed type T objects should provide:
  • a default constructor: T::T()
  • a copy initializer: T::T(T& t)
  • an assignement operator: T& T::operator=(T& t)
  • an equality and less-than operators:
  • bool T::operator==(T& t)
  • bool T::operator<(T& t)
Implementation notes
I suggest to use typedef's like:
typedef VDKBtree<someClass> SomeClassBtree;
Programming tips
Here an example how to construct, fill and trasverse a btree
#define LEN 10
typedef VDKBtree<int> intbt;
int v[LUNG] = { 3, 5, 7, 2, 1, 4, 45, 6, 23, 6 };
int main(int , char **)
{
intbt btree;
// add nodes to tree
for (t=0; t < LEN ;t++)
btree.add(v[t]);
// makes an iterator
intbt::Iterator iter(btree);
for (; iter;iter++)
{
int i = iter.current();
// make whatever with i
}
// removes all nodes
for (t=0; t < LEN; t++)
btree.unlink(v[t]);
}
EXAMPLES
in ./example/template/ttest.cc

Constructor & Destructor Documentation

template<class T >
VDKBtree< T >::VDKBtree ( )
inline

Constructor, makes an empty tree


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