本文整理汇总了C++中ANode::firstPred方法的典型用法代码示例。如果您正苦于以下问题:C++ ANode::firstPred方法的具体用法?C++ ANode::firstPred怎么用?C++ ANode::firstPred使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ANode
的用法示例。
在下文中一共展示了ANode::firstPred方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uTestGraphOwn
/**
* TODO: Check graph's data structures being consistent with node and edge functionality
*/
bool uTestGraphOwn()
{
{
AGraph graph( true);
ANode *dummy = graph.newNode();
graph.deleteNode( dummy);
ANode *pred = graph.newNode();
ANode *succ = graph.newNode();
AEdge *edge = graph.newEdge( pred, succ);
/** Check node insertion */
ANode *new_node = edge->insertNode();
AEdge *edge2 = new_node->firstSucc();
assert( areEqP( new_node->firstPred(), pred->firstSucc()));
assert( areEqP( new_node->firstSucc(), succ->firstPred()));
assert( areEqP( edge->pred(), pred));
assert( areEqP( pred->firstSucc(), edge));
assert( areEqP( edge->succ(), new_node));
assert( areEqP( new_node->firstPred(), edge));
assert( areEqP( edge2->pred(), new_node));
assert( areEqP( edge2->succ(), succ));
assert( areEqP( succ->firstPred(), edge2));
}
/** Test iterators */
{
AGraph graph( true);
ANode *node1 = graph.newNode();
ANode *node2 = graph.newNode();
ANode *node3 = graph.newNode();
AEdge *edge1 = graph.newEdge( node1, node2);
AEdge *edge2 = graph.newEdge( node2, node3);
for ( Node::Succ succ_iter = node2->succsBegin(),
succ_iter_end = node2->succsEnd();
succ_iter != succ_iter_end;
succ_iter++ )
{
assert( areEqP( *succ_iter, edge2));
}
for ( Node::Pred pred_iter = node2->predsBegin(),
pred_iter_end = node2->predsEnd();
pred_iter != pred_iter_end;
pred_iter++ )
{
assert( areEqP( *pred_iter, edge1));
}
Node::EdgeIter edge_iter = node2->edgesBegin();
Node::EdgeIter edge_iter_end = node2->edgesEnd();
assert( edge_iter != edge_iter_end);
assert( areEqP( *edge_iter, edge1) || areEqP( *edge_iter, edge2));
if ( areEqP( *edge_iter, edge1))
{
assert( areEqP( edge_iter.node(), edge1->pred()));
assert( areEqP( edge_iter.node(), node1));
} else
{
assert( areEqP( edge_iter.node(), edge2->succ()));
assert( areEqP( edge_iter.node(), node3));
}
edge_iter++;
assert( edge_iter != edge_iter_end);
assert( areEqP( *edge_iter, edge1) || areEqP( *edge_iter, edge2));
if ( areEqP( *edge_iter, edge1))
{
assert( areEqP( edge_iter.node(), edge1->pred()));
assert( areEqP( edge_iter.node(), node1));
} else
{
assert( areEqP( edge_iter.node(), edge2->succ()));
assert( areEqP( edge_iter.node(), node3));
}
edge_iter++;
assert( edge_iter == edge_iter_end);
}
return true;
}