00001 // BST.hpp - Binary Search Tree Class Interface 00002 00003 #ifndef __BST_HPP__ // Is it defined already !? 00004 #define __BST_HPP__ 00005 00006 #include "Const.hpp" 00007 #include "DBase.hpp" 00008 #include "String.hpp" 00009 #include "BinNode.hpp" 00010 00011 class BinSearchTree { 00012 00013 public: 00014 BinSearchTree(); 00015 00016 virtual ~BinSearchTree(); 00017 00018 00019 void clear(); 00020 void insert( DBase* val ); 00021 00022 void remove(); 00023 void remove( DBase& val ); 00024 int find( DBase& val ); 00025 int findID( String& ID ); 00026 00027 bool isEmpty() const; 00028 int length() const; 00029 int search() const; 00030 void print() const; // Without preorder 00031 void display() const; // With preorder 00032 00033 void clear( BinNode* ); // Helper functions 00034 void insert( BinNode*&, DBase* ); // for public routines 00035 BinNode* deletemin( BinNode*& ); 00036 void remove( BinNode*&, DBase& ); 00037 int find( BinNode*, DBase& ); 00038 int findID( BinNode*, String& ); 00039 00040 void print( BinNode*, int ) const; 00041 00042 BinNode* getCurrent(); 00043 DBase* getValue(); 00044 00045 void preorder( BinNode* rt ) const; // rt is the root of a subtree 00046 00047 private: 00048 BinNode* current; 00049 DBase* currElem; 00050 00051 BinNode* root; 00052 int NbElements; 00053 int searchStep; 00054 }; 00055 00056 #endif