/********* WinTree2.h Second try to get the tree to work in windows. ******/ #ifndef WINTREE2_H // Keeps file from multiply includs... #define WINTREE2_H #include #include // UNICOD not fully suported in 98. #include // For future auto remove... #include // For future use... //********************************************************** //***************** const globals values. ******************* // Number of nodes to hold A...Za...z Data nodes in the tree. const int ciNodeCount = 52; // pause between outputs. const int iWAIT = 40 ; /********************************************************************* The class methods, and private class data members titles are fairly self explanatory. Set****** sets the data, Fetch**** fetched the data. Each class has a constructor and destructor method. *********************************************************************/ // This class is the actual tree nodes. class TreeNode { public: TreeNode(const TCHAR *) ;// Constructor ~TreeNode(); // Destructor // Set Node pointers... void SetLeftPointer(TreeNode* TP) { pLeftPoint = TP; return ;}; void SetRightPointer(TreeNode* TP) { pRightPoint = TP; return ;}; void SetLeftThreadPointer(TreeNode* TP) { pLeftThread = TP; return ;}; void SetParentNodePointer(TreeNode* TP) { pParentNode = TP; return ;}; // Fetch Node pointers... TreeNode* FetchLeftPointer() { return pLeftPoint ;}; TreeNode* FetchRightPointer() { return pRightPoint;}; TreeNode* FetchLeftThreadPointer() { return pLeftThread;}; TreeNode* FetchParentNodePointer() { return pParentNode;}; TCHAR* FetchTreeNodeData() { return szData; }; private: TreeNode *pLeftPoint ; // Node to lower left. TreeNode *pRightPoint ; // Node to lower right. TreeNode *pLeftThread ; // Node at point of last left turn down the tree. TreeNode *pParentNode ; // Parent of this Node if any. If NULL then this node Root. TCHAR *szData; // Node Data; }; // End class TreeNode // This class will be used to collect all current tree data. class TreeData { public: TreeData( TreeNode* ) ; // Constructor ~TreeData() ; // Destructor // Set Node pointers void SetPointerToRoot(TreeNode* pTN) { pRoot = pTN; return; }; void SetPointerLestSignificantNode(TreeNode* pTN) { pLestSignificantNode = pTN; return; }; void SetPointerLastNodeViewed(TreeNode* pTN) { pLastNodeViewed = pTN; return; }; void SetNodeToCurrentTreeMembers(TreeNode &TN) { strcat(szCurrentTreeMembers, TN.FetchTreeNodeData()); return;}; void SetNodeToBeRemoved(TCHAR *szNR) { strcpy(szNodeToRemove, szNR); return; }; void SetFlagUpThread(bool fFlag) { fUpThread = fFlag; return; } ; void SetFlagLastNodeReached(bool fFlag) { fLastNodeReached = fFlag; return; } ; void SetFlagLestSignificantNodeReached(bool fFlag) {fLestSignificantNodeReached = fFlag; return; } ; void CatTNDtoCurrentTreeMembers(TCHAR* szD) { strcat(szCurrentTreeMembers, szD ); } ; void VoidOutCurrentTreeMembers() { strcpy( szCurrentTreeMembers, "\0" ) ; } ; TreeNode* FetchPointerToRoot() { return pRoot; }; TreeNode* FetchPointerLestSignificantNode() { return pLestSignificantNode; }; TreeNode* FetchPointerLastNodeViewed() { return pLastNodeViewed; }; TCHAR* FetchCurrentTreeMembers() { return szCurrentTreeMembers;}; TCHAR* FetchNodeToBeRemoved() { return szNodeToRemove; }; bool FetchFlagUpThread() { return fUpThread; }; bool FetchFlagLastNodeReached() { return fLastNodeReached; }; bool FetchFlagLestSignificantNodeReached() { return fLestSignificantNodeReached ; } ; private: TreeNode *pRoot; // Current tree root address. TreeNode *pLestSignificantNode; // Lest Significant Node has data member with lowest value. A...Za...z TreeNode *pLastNodeViewed; // Last Node viewed in last walk through tree. TCHAR szCurrentTreeMembers[60]; // Current Nodes in Tree. TCHAR szNodeToRemove[1]; // The next Node in the Tree to be removed. bool fUpThread ; // Has a Thread been walked up? bool fLastNodeReached; // Has the last Node in the tree been reached? bool fLestSignificantNodeReached; // Has the Lest Significant Node been readhed? }; // End class TreeData // ************************************************************ // ++++++++++++++++++ Function prototypes. ++++++++++++++++++++ // Creates Tree with 52 Nodes A...Za...z data members. Returns Root pointer. TreeNode* CreateTree() ; // Place a node in the tree according to it data member's value. bool Position(TreeNode*, TreeNode*); // Test to see if Data Tree Exist? bool DoesTreeExist(TreeData*) ; // Will walk through tree and return with all current node data in ascending order. void FetchAllTreeData(TreeData*); // Will remove the lest significant node, and percolate best of the remaining nodes to // take the place of the node that was removed. void RemoveLestSignificantNode(TreeData*); // These functions do the pointer reassignments that are the percolation process. // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // ++++++++++ Percolation function prototypes. ++++++++++++++++ void Perco_one (TreeNode* pNR, TreeNode* pPI ) ; void Perco_two (TreeNode* pNR, TreeNode* pPI ) ; void Perco_three(TreeNode* pNR, TreeNode* pPI, TreeNode* pNP ) ; void Perco_four (TreeNode* pNR, TreeNode* pPI, TreeNode* pNP ) ; void Perco_five (TreeNode* pNR, TreeNode* pPI, TreeNode* pNP, TreeNode* pPII ) ; void Perco_six (TreeNode* pNR, TreeNode* pPI, TreeNode* pNP, TreeNode* pPII ) ; TreeNode* Perco_seven(TreeNode* pR, TreeNode* pNR, TreeNode* pNP ) ; TreeNode* Perco_eight(TreeNode* pR, TreeNode* pNR, TreeNode* pNP ) ; TreeNode* Perco_nine (TreeNode* pR, TreeNode* pNR, TreeNode* pNP, TreeNode* pPII ) ; void Perco_ten (TreeNode* pNR, TreeNode* pPI, TreeNode* pNP ) ; void Perco_eleven(TreeNode* pNR, TreeNode* pPI, TreeNode* pNP); TreeNode* Perco_twelve(TreeNode* pR) ; // ------------------ Function prototypes --------------------- // ************************************************************ #endif // End of the ifndef.....