home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / base / treewalk.h < prev    next >
C/C++ Source or Header  |  1995-04-08  |  2KB  |  106 lines

  1.  
  2.  
  3. #ifndef _treewalk_h_ /* Tue Mar 15 12:28:42 1994 */
  4. #define _treewalk_h_
  5.  
  6.  
  7.  
  8.  
  9.  
  10. /*
  11.  *
  12.  *          Copyright (C) 1994, M. A. Sridhar
  13.  *  
  14.  *
  15.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  16.  *     to copy, modify or distribute this software  as you see fit,
  17.  *     and to use  it  for  any  purpose, provided   this copyright
  18.  *     notice and the following   disclaimer are included  with all
  19.  *     copies.
  20.  *
  21.  *                        DISCLAIMER
  22.  *
  23.  *     The author makes no warranties, either expressed or implied,
  24.  *     with respect  to  this  software, its  quality, performance,
  25.  *     merchantability, or fitness for any particular purpose. This
  26.  *     software is distributed  AS IS.  The  user of this  software
  27.  *     assumes all risks  as to its quality  and performance. In no
  28.  *     event shall the author be liable for any direct, indirect or
  29.  *     consequential damages, even if the  author has been  advised
  30.  *     as to the possibility of such damages.
  31.  *
  32.  */
  33.  
  34.  
  35.  
  36. // The PostOrderWalker is an iterator that walks through a CL_Tree in
  37. // postorder.
  38.  
  39. #ifdef __GNUC__
  40. #pragma interface
  41. #endif
  42.  
  43. #include "base/tree.h"
  44.  
  45.  
  46. // The PostOrderWalker is an iterator that walks through a (subtree of a)
  47. // CL_Tree in postorder.
  48.  
  49.  
  50. template <class ItemType>
  51. class CL_EXPORT CL_PostOrderWalker: public CL_Object {
  52.  
  53. public:
  54.     CL_PostOrderWalker (CL_TreeNode<ItemType>* node);
  55.     // Constructor: to walk the subtree rooted at the given node.
  56.  
  57.     ~CL_PostOrderWalker ();
  58.     
  59.     void Reset ();
  60.  
  61.     bool More  ();
  62.  
  63.     CL_TreeNode<ItemType>* Next();
  64.  
  65. protected:
  66.     CL_TreeNode<ItemType>*    _subtreeRoot;
  67.     CL_ObjectSequence         _stack;
  68. };
  69.  
  70.  
  71.  
  72.  
  73.  
  74. // The PreOrderWalker is an iterator that walks through a CL_Tree in
  75. // preorder.
  76.  
  77.  
  78.  
  79. template <class ItemType>
  80. class CL_EXPORT CL_PreOrderWalker: public CL_Object {
  81.  
  82. public:
  83.     CL_PreOrderWalker (CL_TreeNode<ItemType>* node);
  84.     // Constructor: to walk the subtree rooted at the given node.
  85.  
  86.     ~CL_PreOrderWalker ();
  87.  
  88.     void Reset ();
  89.  
  90.     bool More  ();
  91.  
  92.     CL_TreeNode<ItemType>* Next();
  93.  
  94. protected:
  95.     CL_TreeNode<ItemType>*    _subtreeRoot;
  96.     CL_ObjectSequence         _stack;
  97. };
  98.  
  99.  
  100.  
  101. #ifndef _no_cl_treewalk_typedefs_
  102. #include "base/treewdef.h"
  103. #endif
  104.  
  105. #endif /* _treewalk_h_ */
  106.