本文整理汇总了C++中Traversal::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ Traversal::reset方法的具体用法?C++ Traversal::reset怎么用?C++ Traversal::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Traversal
的用法示例。
在下文中一共展示了Traversal::reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeFullTreeTraversal
bool Model::computeFullTreeTraversal(Traversal & traversal, const LinkIndex traversalBase) const
{
if( traversalBase < 0 || traversalBase >= (LinkIndex)this->getNrOfLinks() )
{
reportError("Model","computeFullTreeTraversal","requested traversalBase is out of bounds");
return false;
}
// Resetting the traversal for populating it
traversal.reset(*this);
// A link is considered visit when all its child (given the traversalBase)
// have been added to the traversal
std::deque<stackEl> linkToVisit;
// We add as first link the requested traversalBase
addBaseLinkToTraversal(*this,traversal,traversalBase,linkToVisit);
// while there is some link still to visit
while( linkToVisit.size() > 0 )
{
assert(linkToVisit.size() <= this->getNrOfLinks());
// DPS : we use linkToVisit as a stack
LinkConstPtr visitedLink = linkToVisit.back().link;
LinkConstPtr visitedLinkParent = linkToVisit.back().parent;
LinkIndex visitedLinkIndex = visitedLink->getIndex();
linkToVisit.pop_back();
for(unsigned int neigh_i=0; neigh_i < this->getNrOfNeighbors(visitedLinkIndex); neigh_i++ )
{
// add to the stack all the neighbors, except for parent link
// (if the visited link is the base one, add all the neighbors)
// the visited link is already in the Traversal, so we can use it
// to check for its parent
Neighbor neighb = this->getNeighbor(visitedLinkIndex,neigh_i);
if( visitedLinkParent == 0 || neighb.neighborLink != visitedLinkParent->getIndex() )
{
addLinkToTraversal(*this,traversal,neighb.neighborLink,
neighb.neighborJoint,visitedLink->getIndex(),linkToVisit);
}
}
}
// At this point the traversal should contain all the links
// of the model
assert(traversal.getNrOfVisitedLinks() == this->getNrOfLinks());
return true;
}