home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / COMPILER / AUTHORS / TREELINK.HPP < prev    next >
Text File  |  1993-05-07  |  5KB  |  87 lines

  1. //+----------------------------------------------------------------------------+
  2. //| TREELINK.HPP                                                               |
  3. //|                                                                            |
  4. //| COPYRIGHT:                                                                 |
  5. //| ----------                                                                 |
  6. //|  Copyright (C) International Business Machines Corp., 1992,1993.           |
  7. //|                                                                            |
  8. //| DISCLAIMER OF WARRANTIES:                                                  |
  9. //| -------------------------                                                  |
  10. //|  The following [enclosed] code is sample code created by IBM Corporation.  |
  11. //|  This sample code is not part of any standard IBM product and is provided  |
  12. //|  to you solely for the purpose of assisting you in the development of      |
  13. //|  your applications.  The code is provided "AS IS", without warranty of     |
  14. //|  any kind.  IBM shall not be liable for any damages arising out of your    |
  15. //|  use of the sample code, even if they have been advised of the             |
  16. //|  possibility of such damages.                                              |
  17. //|                                                                            |
  18. //| REVISION LEVEL: 1.0                                                        |
  19. //| ---------------                                                            |
  20. //|                                                                            |
  21. //+----------------------------------------------------------------------------+
  22. //| Class Name : TREELINK                                                      |
  23. //| Purpose    : This class encapsulates the links to the immediate neighbours |
  24. //|              in the n-ary tree.                                            |
  25. //| Author     : njC Sales                                                     |
  26. //| Date       : 27 October 1992                                               |
  27. //+----------------------------------------------------------------------------+
  28.  
  29. #ifndef TREELINK_HPP_INCLUDED
  30. #define TREELINK_HPP_INCLUDED
  31.  
  32. class TreeLink
  33. {
  34. public:
  35.    //+-------------------------------------------------------------------------+
  36.    //| Define default constructor, copy constructor, and assignment override   |
  37.    //+-------------------------------------------------------------------------+
  38.    TreeLink() : parentLink(0), childLink(0),
  39.                 leftLink(0), rightLink(0) {}
  40.  
  41.    TreeLink(TreeLink *link)  :
  42.       parentLink(link->parentLink),
  43.       childLink(link->childLink),
  44.       leftLink(link->leftLink),
  45.       rightLink(link->rightLink) {}
  46.  
  47.    TreeLink(const TreeLink &link) :
  48.       parentLink(link.parentLink),
  49.       childLink(link.childLink),
  50.       leftLink(link.leftLink),
  51.       rightLink(link.rightLink) {}
  52.  
  53.    TreeLink &operator= (const TreeLink &tLink);
  54.  
  55.    virtual ~TreeLink() {}
  56.  
  57.    //+-------------------------------------------------------------------------+
  58.    //| Define accessors                                                        |
  59.    //+-------------------------------------------------------------------------+
  60.    virtual TreeLink *getParent()   {return parentLink;}
  61.    virtual TreeLink *getChild()    {return childLink;}
  62.    virtual TreeLink *getLeft()     {return leftLink;}
  63.    virtual TreeLink *getRight()    {return rightLink;}
  64.  
  65.    //+-------------------------------------------------------------------------+
  66.    //| Define state changing functions                                         |
  67.    //+-------------------------------------------------------------------------+
  68.    void setParent(TreeLink *link) {parentLink= link;}
  69.    void setChild (TreeLink *link) {childLink= link;}
  70.    void setLeft  (TreeLink *link) {leftLink= link;}
  71.    void setRight (TreeLink *link) {rightLink= link;}
  72.    void clearParent()             {parentLink= 0;}
  73.    void clearChild()              {childLink= 0;}
  74.    void clearLeft()               {leftLink= 0;}
  75.    void clearRight()              {rightLink= 0;}
  76.  
  77. private:
  78.    TreeLink *parentLink, *childLink, *leftLink, *rightLink;
  79.  
  80. // friend TreeLink *adopt   (TreeLink *parent,       TreeLink *child);
  81. // friend TreeLink *insert  (TreeLink *currentChild, TreeLink *newChild);
  82. // friend TreeLink *addfirst(TreeLink *parent,       TreeLink *newChild);
  83. // friend TreeLink *add     (TreeLink *currentChild, TreeLink *newChild);
  84. // friend TreeLink *delink  (TreeLink *currentNode);
  85. };
  86. #endif
  87.