Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/DataType/BST/BinNode.hpp

Go to the documentation of this file.
00001 // BinNode.hpp - Binary Search Tree Node Class Interface
00002 
00003 #ifndef __BINNODE_HPP__           // Is it defined already !?
00004 #define __BINNODE_HPP__
00005 
00006 #include "Const.hpp"
00007 #include "DBase.hpp"
00008 #include "String.hpp"
00009 
00010 class BinNode {                // Binary tree node class
00011 public:
00012   static BinNode* freelist;
00013 
00014   // Two constructors -- with and without initial values
00015   BinNode();
00016 
00017   BinNode( DBase* e );
00018   BinNode( DBase* e, BinNode* l );
00019   BinNode( DBase* e, BinNode* l, BinNode* r );
00020 
00021   virtual ~BinNode();               // Destructor
00022 
00023   BinNode* leftchild()  const;
00024   BinNode* rightchild() const;
00025 
00026   DBase&   value();
00027 
00028   int      CompareID( String& ID )  const;
00029   int      CompareID( DBase&  db )  const;
00030 
00031     
00032   void     setValue(DBase& val);
00033 
00034   bool     isLeaf()   const;        // Return TRUE if is a leaf
00035   bool     valid()    const;    // Return TRUE if element is not NULL
00036 
00037   DBase*   getElem();
00038 
00039   void* operator new(size_t);       // Overload new  
00040   void  operator delete(void*);     // Overload delete
00041 
00042   BinNode* left;                    // Pointer to left child
00043   BinNode* right;                   // Pointer to right child
00044 
00045   // Inline optimization
00046 inline void   display() const       // Display the DBase content
00047 {                                   // on the Screen.
00048     cout << element->string() << endl;
00049 }
00050 
00051 inline friend ostream& operator<<(ostream& os, BinNode* node) { 
00052   return os << node->element->string() << endl;
00053 }
00054 
00055 
00056 private:
00057   DBase*   element;                 // The node's value
00058 };
00059 
00060 #endif

Generated on Sun Oct 14 18:46:17 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001