home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mandlcpp.zip / tree.cpp < prev    next >
C/C++ Source or Header  |  1993-06-13  |  1KB  |  66 lines

  1. #include "tree.h"
  2. #ifdef INCLUDESOURCE
  3. #include "chain.cc"
  4. #endif
  5.  
  6.  
  7. int tree::toBeCalledForeachElement(unsigned int iMsg, void *pDummy)
  8. {    int ret;
  9.  
  10.     if (iMsg <= idForeachChainElementLast)
  11.         return chainElement::toBeCalledForeachElement(iMsg, pDummy);
  12.     switch (ret = toBeCalledPre(iMsg, pDummy))
  13.     {    case 0:
  14.             break;
  15.         case -1:
  16.             return 0;
  17.         default:
  18.             return ret;
  19.     }
  20.     if (ret = foreach(iMsg, pDummy))
  21.         return ret;
  22.     return toBeCalledPost(iMsg, pDummy);
  23. }
  24.  
  25.  
  26. int tree::toBeCalledPre(unsigned int iMsg, void *pDummy)
  27. {    switch (iMsg)
  28.     {    case idForeachTreeDestructPostChilds:
  29.             return 0;
  30.         case idForeachTreeSort:
  31.             bubbleSort((unsigned int)pDummy);
  32.             return 0;
  33.         default:
  34.             if (iMsg > idForeachTreeLast)
  35.                 abort();
  36.             return 0;
  37.     }
  38. }
  39.  
  40.  
  41. int tree::toBeCalledPost(unsigned int iMsg, void *pDummy)
  42. {       (void)pDummy;
  43.     switch (iMsg)
  44.     {    case idForeachTreeDestructPostChilds:
  45.             delete this;
  46.             return 0;
  47.         default:
  48.             return 0;
  49.     }
  50. }
  51.  
  52.  
  53. tree::~tree(void)
  54. {
  55. }
  56.  
  57.  
  58. tree::tree(chain *pParent):chainElement(pParent), chain()
  59. {
  60. }
  61.  
  62.  
  63. void tree::bubbleSortTree(unsigned int iMsg)
  64. {    toBeCalledForeachElement(idForeachTreeSort, (void*)iMsg);
  65. }
  66.