home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / BCCollec / Structs / Trees / BCTree.h < prev   
Encoding:
Text File  |  1994-04-21  |  1.5 KB  |  61 lines  |  [TEXT/MPS ]

  1. //  The C++ Booch Components (Version 2.1)
  2. //  (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
  3. //
  4. //  BCBTree.h
  5. //
  6. //  This file contains the declaration of the binary tree.
  7.  
  8. #ifndef BCBTREE_H
  9. #define BCBTREE_H 1
  10.  
  11. #include "BCNodes.h"
  12.  
  13. enum BC_Child {BC_kLeft, BC_kRight};
  14.   
  15. // Binary tree
  16.  
  17. template<class Item, class StorageManager>
  18. class BC_TBinaryTree {
  19. public:
  20.  
  21.   BC_TBinaryTree();
  22.   BC_TBinaryTree(const BC_TBinaryTree<Item, StorageManager>&);
  23.   ~BC_TBinaryTree();
  24.  
  25.   BC_TBinaryTree<Item, StorageManager>&
  26.     operator=(const BC_TBinaryTree<Item, StorageManager>&);
  27.   BC_Boolean operator==(const BC_TBinaryTree<Item, StorageManager>&) const;
  28.   BC_Boolean operator!=(const BC_TBinaryTree<Item, StorageManager>&) const;
  29.  
  30.   void Clear();
  31.   void Insert(const Item&, BC_Child child);
  32.   void Append(const Item&, BC_Child child, BC_Child after);
  33.   void Remove(BC_Child child);
  34.   void Share(BC_TBinaryTree<Item, StorageManager>&, BC_Child child);
  35.   void SwapChild(BC_TBinaryTree<Item, StorageManager>&, BC_Child child);
  36.   void Child(BC_Child child);
  37.   void LeftChild();
  38.   void RightChild();
  39.   void Parent();
  40.   void SetItem(const Item&);
  41.  
  42.   BC_Boolean HasChildren() const;
  43.   BC_Boolean IsNull() const;
  44.   BC_Boolean IsShared() const;
  45.   BC_Boolean IsRoot() const;
  46.   const Item& ItemAt() const;
  47.   Item& ItemAt();
  48.  
  49.   static void* operator new(size_t);
  50.   static void operator delete(void*, size_t);
  51.  
  52. protected:
  53.  
  54.   BC_TBinaryNode<Item, StorageManager>* fRep;
  55.  
  56.   void Purge(BC_TBinaryNode<Item, StorageManager>*&);
  57.  
  58. };
  59.  
  60. #endif
  61.