atree.cpp
来自「数据结构与程序设计教材源码 数据结构与程序设计教材源码」· C++ 代码 · 共 42 行
CPP
42 行
template <class Record>
Error_code AVL_tree<Record>::insert(const Record &new_data)
/*
Post: If the key of new_data is already in the AVL_tree, a code
of duplicate_error is returned.
Otherwise, a code of success is returned and the Record new_data
is inserted into the tree in such a way that the properties of
an AVL tree are preserved.
Uses: avl_insert.
*/
{
bool taller;
return avl_insert(root, new_data, taller);
}
template <class Record>
Error_code AVL_tree<Record>::remove(const Record &target)
{
bool shorter;
return remove_avl(root, target, shorter);
}
template <class Record>
void AVL_tree<Record>::prenode(void (*f)(Binary_node<Record> *&))
{
avl_prenode(root, f);
}
template <class Record>
void avl_prenode(Binary_node<Record> *root, void (*f)(Binary_node<Record> *&))
{
if (root != NULL) {
(*f)(root);
avl_prenode(root->left, f);
avl_prenode(root->right, f);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?