本文整理汇总了C++中tree_t::purge方法的典型用法代码示例。如果您正苦于以下问题:C++ tree_t::purge方法的具体用法?C++ tree_t::purge怎么用?C++ tree_t::purge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree_t
的用法示例。
在下文中一共展示了tree_t::purge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clear
// Clear environment.
void clear(void)
{
tree_t::iter it;
node *n;
it.start_iter_least(tree);
// A useful property of this data structure is the ability to do a
// "death march" through it. Once the iterator (forward or backward)
// has stepped past a node, the node is not accessed again (assuming
// you don't reverse the direction of iteration). If you are doing
// a final iteration in order to destroy the tree, you can release
// heap memory or other resources allocated by the tree node once the
// iterator has stepped past it. If you plan to use the AVL tree
// instance again after completing this final iteration, you must
// make it empty (set the root to the null value).
for (n = *it; n; n = *it)
{
// Step iterator past node n.
it++;
// Release node n's resources.
delete [] n->name;
delete [] n->value;
delete n;
}
// Make the tree empty by setting root to null value.
tree.purge();
}