本文整理汇总了C++中tree::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::erase方法的具体用法?C++ tree::erase怎么用?C++ tree::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::erase方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clean_pattern
/**
Clean the possible patterns annotations:
$enter_new_statement ...
*/
void clean_pattern(tree<AstNode>& tr) {
for (tree<AstNode>::iterator iter=tr.begin(); iter!=tr.end(); ++iter) {
if (iter->getType() == "text" && iter->getValue() == "$enter_the_new_statement") {
iter = rewind(iter, "statement", tr);
tr.erase(iter);
break;
}
}
}
示例2: RemoveItem
void CFileTree::RemoveItem(char *absolutePath)
{
tree_node_<FILE_ITEM>* node = findNodeFromRootWithPath(absolutePath);
if (node != NULL) {
filesTree.erase(tree<FILE_ITEM>::iterator(node));
}
else {
//printf("Do not find node for path : %s\n", absolutePath);
}
DisplayTree(topNode.node, 0);
}
示例3: bool
typename tree<T>::iterator
remove_if (tree <T> & Q, typename tree<T>::iterator n,
bool (*pred_fun) (T) ) {
typename tree<T>::iterator c ;
if (pred_fun (*n) )
n = Q.erase(n);
else {
c = n.lchild();
while (c != Q.end()) c = remove_if (Q, c, pred_fun);
n++;
} // end if
return n;
}
示例4: mergeNodes
void mergeNodes(tree<T> &intree)
{
// First, determine which top node has the shallowest depth
int minimal_d(1000);
for(typename tree<T>::leaf_iterator c = intree.begin_leaf();c != intree.end_leaf();++c){
int this_depth(intree.depth(c));
if(this_depth < minimal_d) minimal_d = this_depth;
} // End c
if(minimal_d == -1) return;
typedef std::map<T, typename tree<T>::iterator> Info;
auto now(intree.begin());
//const int max_depth(intree.max_depth()-1);
const int max_depth(minimal_d);
for(int depth = 0;depth < max_depth;++depth){
typename tree<T>::fixed_depth_iterator itr_begin(intree.begin_fixed(intree.begin(), depth));
Info siblings;
while(intree.is_valid(itr_begin)){
int counts(siblings.count(*itr_begin));
typename tree<T>::fixed_depth_iterator itr_next(intree.next_at_same_depth(itr_begin));
// If current node and the next node are same, combine them
if(!counts){
typename tree<T>::iterator current(itr_begin);
siblings.insert(typename Info::value_type(*itr_begin, current));
} // End if
else{
typename tree<T>::iterator current(itr_begin);
typename tree<T>::iterator next(siblings[*itr_begin]);
intree.merge(intree.begin(next), intree.end(next), intree.begin(current), intree.end(current));
#ifdef _DEBUG_TREE
std::cout << "C: " << *current << " == N: " << *next << std::endl;
#endif
typename tree<T>::iterator c_back(itr_begin);
const int mydepth(intree.depth(c_back));
c_back -= mydepth;
intree.erase(c_back); // Erase the redundunt nodes
} // End else
itr_begin = itr_next;
} // End while
} // End depth
}
示例5: CleanUpFormTag
/*!
* \fn static void CleanUpFormTag(tree<HTML::Node> &m_TagTree);
* \brief 剪枝,去除scrip等无用节点
* \param [in]DOM树
* \return void
* \date 2011-06-01
* \author nanjunxiao
*/
void Pretreat::CleanUpFormTag(tree<HTML::Node> &m_TagTree)
{
set<string> m_sCleanFormSet;
m_sCleanFormSet.insert("input");
m_sCleanFormSet.insert("noembed");
m_sCleanFormSet.insert("noscript");
m_sCleanFormSet.insert("textarea");
m_sCleanFormSet.insert("marquee");
m_sCleanFormSet.insert("object");
m_sCleanFormSet.insert("select");
m_sCleanFormSet.insert("iframe");
m_sCleanFormSet.insert("style");
m_sCleanFormSet.insert("script");
tree<HTML::Node>::iterator itTagTreeBegin = m_TagTree.begin();
tree<HTML::Node>::iterator itTagTreeEnd = m_TagTree.end();
while ( itTagTreeBegin != itTagTreeEnd )
{
//遍历标签树,标签节点且节点名称在m_sCleanFormSet中则把标签节点在标签树上删除
if ( itTagTreeBegin->isTag() )
{
string sTagName = itTagTreeBegin->tagName();
if ( m_sCleanFormSet.find(sTagName) != m_sCleanFormSet.end() )
{
tree<HTML::Node>::sibling_iterator sibTmp = itTagTreeBegin;
sibTmp++;
m_TagTree.erase( itTagTreeBegin );
itTagTreeBegin = sibTmp;
}
else
{
itTagTreeBegin++ ;
}
}//end if
else
{
itTagTreeBegin++;
}
}//end while
}
示例6: insert
inline void insert(int key,int val){
int x = root;
int k = 0 ;
for(;;)
{
if(key == keys[x])
{
mp.erase(mp.find(vals[x]));
vals[x] = val;
Splay(x,0);
return;
}
int f = (key > keys[x]);
if(ch[x][f] == 0 )
{
NewNode(ch[x][f],key,val);
pre[ch[x][f]] = x;
Splay(ch[x][f],0);
return;
}else{
x = ch[x][f];
}
}
}
示例7: move_branch
/**
Move all the branches from 'from' to 'where' on the tree 'tr_where'
*/
void move_branch(const tree<AstNode>::iterator& where, const tree<AstNode>::iterator& from, tree<AstNode>& tr_where)
{
copy_branch(where, from, tr_where);
tr_where.erase(from);
}