当前位置: 首页>>代码示例>>C++>>正文


C++ tree_t::purge方法代码示例

本文整理汇总了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();
      }
开发者ID:wkaras,项目名称:C-plus-plus-intrusive-container-templates,代码行数:32,代码来源:avl_ex1.cpp


注:本文中的tree_t::purge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。