gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
BST< BST_TYPE > Class Template Reference

#include <BST.H>

Collaboration diagram for BST< BST_TYPE >:
[legend]

Public Types

typedef int(BST_TYPE::* BSTCompareMethod) (const BST_TYPE &) const
 The comparison typedefinition. More...
 

Public Member Functions

 BST (BST_TYPE *v=NULL, BST *cL=NULL, BST *cR=NULL)
 
 ~BST (void)
 Destructor - any resident variable or children are deleted. More...
 
int add (BST_TYPE *v, BSTCompareMethod compare=NULL)
 
int sort (LinkList< BST_TYPE *> *linkList, BSTCompareMethod compare=NULL)
 
void removeSorted (LinkList< BST_TYPE *> *linkList)
 

Private Attributes

BSTchildL
 
BSTchildR
 Left and right children nodes. More...
 
BST_TYPE * value
 The pointer to the variable. More...
 

Detailed Description

template<class BST_TYPE>
class BST< BST_TYPE >

Binary Search Tree This class is useful for generating an ordered Binary Tree. This is simple and fast for sorting your data.

Template Parameters
BST_TYPEthe type of the variables (values) to be stored/sorted.
Examples:
BSTTest.C.

Definition at line 35 of file BST.H.

Member Typedef Documentation

◆ BSTCompareMethod

template<class BST_TYPE>
typedef int(BST_TYPE::* BST< BST_TYPE >::BSTCompareMethod) (const BST_TYPE &) const

The comparison typedefinition.

Definition at line 41 of file BST.H.

Constructor & Destructor Documentation

◆ BST()

template<class BST_TYPE>
BST< BST_TYPE >::BST ( BST_TYPE *  v = NULL,
BST< BST_TYPE > *  cL = NULL,
BST< BST_TYPE > *  cR = NULL 
)
inline

Constructor

Parameters
va supplied value to store locally. Defaults to NULL
cLleft child value. Defaults to NULL
cRright child value. Defaults to NULL

Definition at line 48 of file BST.H.

◆ ~BST()

template<class BST_TYPE>
BST< BST_TYPE >::~BST ( void  )
inline

Destructor - any resident variable or children are deleted.

Definition at line 55 of file BST.H.

Member Function Documentation

◆ add()

template<class BST_TYPE>
int BST< BST_TYPE >::add ( BST_TYPE *  v,
BSTCompareMethod  compare = NULL 
)
inline

Add a new variable to the BST. This method is a recursive evaluate and store method.

Parameters
vthe new variable to add
comparethe comparison method to use (should be true if v>value), if NULL then check using v>value
Returns
BST_OK if OK, otherwise, BST_MALLOC_ERROR

Definition at line 70 of file BST.H.

◆ removeSorted()

template<class BST_TYPE>
void BST< BST_TYPE >::removeSorted ( LinkList< BST_TYPE *> *  linkList)
inline

Remove from the tree adding to the LinkList<BST_TYPE *> is a sorted manner. This yields a sorted linkList.

Parameters
linkListthe pointer to the LinkList<BST_TYPE *> to add the value to.

Definition at line 115 of file BST.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sort()

template<class BST_TYPE>
int BST< BST_TYPE >::sort ( LinkList< BST_TYPE *> *  linkList,
BSTCompareMethod  compare = NULL 
)
inline

Take a LinkList<BST_TYPE *> and sort it.

Parameters
linkLista pointer to the LinkList<BST_TYPE> to sort.
comparethe method for comparing two values, see add.
Returns
BST_OK on success. On failure, returns <0 AND the original contents of the linkList may be partially in both the BST and the LinkList<BST_TYPE *>

Definition at line 101 of file BST.H.

Here is the call graph for this function:

Member Data Documentation

◆ childL

template<class BST_TYPE>
BST* BST< BST_TYPE >::childL
private

Definition at line 36 of file BST.H.

◆ childR

template<class BST_TYPE>
BST * BST< BST_TYPE >::childR
private

Left and right children nodes.

Definition at line 36 of file BST.H.

◆ value

template<class BST_TYPE>
BST_TYPE* BST< BST_TYPE >::value
private

The pointer to the variable.

Definition at line 37 of file BST.H.


The documentation for this class was generated from the following file:
gtkIOStream: BST< BST_TYPE > Class Template Reference
GTK+ IOStream  Beta