本文整理汇总了C++中LIST::get_elem_count方法的典型用法代码示例。如果您正苦于以下问题:C++ LIST::get_elem_count方法的具体用法?C++ LIST::get_elem_count怎么用?C++ LIST::get_elem_count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LIST
的用法示例。
在下文中一共展示了LIST::get_elem_count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sort_in_bfs_order
//'order_buf': record the bfs-order for each vertex.
void DGRAPH::sort_in_bfs_order(SVECTOR<UINT> & order_buf, GRAPH & domtree,
VERTEX * root)
{
LIST<VERTEX*> worklst;
worklst.append_tail(root);
UINT order = 1;
while (worklst.get_elem_count() > 0) {
VERTEX * sv = worklst.remove_head();
order_buf.set(VERTEX_id(sv), order);
order++;
EDGE_C * el = VERTEX_out_list(sv);
while (el != NULL) {
VERTEX * to = EDGE_to(EC_edge(el));
worklst.append_tail(to);
el = EC_next(el);
}
}
}
示例2: 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;
}