本文整理汇总了C++中tree::end_leaf方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::end_leaf方法的具体用法?C++ tree::end_leaf怎么用?C++ tree::end_leaf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::end_leaf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: onMonitoringEnabled
void onMonitoringEnabled(const tree<core::FileInfo>& files)
{
enqueFiles(files.begin_leaf(), files.end_leaf());
}