bst.h
来自「经典c++程序的实现」· C头文件 代码 · 共 24 行
H
24 行
class BST {
private:
BinNode* root;
void clearhelp(BinNode*); // Helper functions
void inserthelp(BinNode*&, const BELEM); // for public routines
void removehelp(BinNode*&, const BELEM);
BinNode* findhelp(BinNode*, const BELEM) const;
void printhelp(const BinNode*, const int) const;
public:
BST() { root = NULL; }
~BST() { clearhelp(root); }
void clear() { clearhelp(root); root = NULL; }
void insert(const BELEM& val) { inserthelp(root, val); }
void remove(const BELEM& val) { removehelp(root, val); }
BinNode* deletemin(BinNode*&);
BinNode* find(const BELEM& val) const
{ return findhelp(root, val); }
bool isEmpty() const { return root == NULL; }
void print() const {
if (root == NULL) cout << "The BST is empty.\n";
else printhelp(root, 0);
}
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?