本文整理汇总了C++中LIST::clean方法的典型用法代码示例。如果您正苦于以下问题:C++ LIST::clean方法的具体用法?C++ LIST::clean怎么用?C++ LIST::clean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LIST
的用法示例。
在下文中一共展示了LIST::clean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tmp
/*
Sort graph vertices in topological order.
'vex_vec': record nodes with topological sort.
NOTE: current graph will be empty at function return.
If one need to keep the graph unchanged, clone graph
as a tmpgraph and operate on the tmpgraph.
e.g: GRAPH org;
And org must be unchanged,
GRAPH tmp(org);
tmp.sort_in_toplog_order(...)
*/
bool GRAPH::sort_in_toplog_order(OUT SVECTOR<UINT> & vex_vec, bool is_topdown)
{
IS_TRUE(m_pool != NULL, ("Graph still not yet initialize."));
if (get_vertex_num() == 0) {
return true;
}
LIST<VERTEX*> vlst;
UINT pos = 0;
vex_vec.clean();
vex_vec.grow(get_vertex_num());
while (this->get_vertex_num() != 0) {
vlst.clean();
VERTEX * v;
INT c;
for (v = this->get_first_vertex(c);
v != NULL; v = this->get_next_vertex(c)) {
if (is_topdown) {
if (VERTEX_in_list(v) == NULL) {
vlst.append_tail(v);
}
} else if (VERTEX_out_list(v) == NULL) {
vlst.append_tail(v);
}
}
if (vlst.get_elem_count() == 0 && this->get_vertex_num() != 0) {
IS_TRUE(0, ("exist cycle in graph"));
return false;
}
for (v = vlst.get_head(); v != NULL; v = vlst.get_next()) {
vex_vec.set(pos, VERTEX_id(v));
pos++;
this->remove_vertex(v);
}
}
return true;
}