gentree.h

来自「经典c++程序的实现」· C头文件 代码 · 共 25 行

H
25
字号
class GTNode {
public:
  GTNode(const ELEM);              // Constructor
  ~GTNode();                       // Destructor
  ELEM value();                    // Return node's value
  bool isLeaf();                   // TRUE if node is a leaf
  GTNode* parent();                // Return node's parent
  GTNode* leftmost_child();        // Return node's first child
  GTNode* right_sibling();         // Return node's right sibling
  void setValue(ELEM);             // Set node's value
  void insert_first(GTNode* n);    // Insert as the first child
  void insert_next(GTNode* n);     // Insert as the right sibling
  void remove_first();             // Remove first child from tree
  void remove_next();              // Remove right sibling from tree
};

class GenTree {
public:
  GenTree();                       // Constructor
  ~GenTree();                      // Destructor
  void clear();                    // Send all nodes to free store
  GTNode* root();                  // Return the root of the tree
  void newroot(ELEM, GTNode*, GTNode*); // Combine two trees
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?