本文整理汇总了C++中ListIterator::pred方法的典型用法代码示例。如果您正苦于以下问题:C++ ListIterator::pred方法的具体用法?C++ ListIterator::pred怎么用?C++ ListIterator::pred使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListIterator
的用法示例。
在下文中一共展示了ListIterator::pred方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void RadialTreeLayout::Grouping::computeAdd(double &D, double &W)
{
D = W = 0;
ListIterator<Group> it;
for(it = begin(); it.valid(); ++it)
{
Group &g = *it;
D += g.m_sumD;
if(g.m_leafGroup == true)
continue;
W += g.m_sumW;
ListIterator<Group> itL;
itL = it.pred();
if(itL.valid() == false) {
g.m_leftAdd = 0.0;
} else {
ListIterator<Group> itR = itL.pred();
if(itR.valid() == false)
g.m_leftAdd = (*itL).m_sumD;
else
g.m_leftAdd = (*itL).m_sumD * g.m_sumW / (*itR).m_sumW;
}
itL = it.succ();
if(itL.valid() == false) {
g.m_leftAdd = 0.0;
} else {
ListIterator<Group> itR = itL.succ();
if(itR.valid() == false)
g.m_leftAdd = (*itL).m_sumD;
else
g.m_leftAdd = (*itL).m_sumD * g.m_sumW / (*itR).m_sumW;
}
}
}
示例2: doCall
//.........这里部分代码省略.........
//------------------------------------------------
//successively check the node against the existing
//clique candidates
//run through the clique candidates to find a matching
//node set
bool setFound = false;
ListIterator< List<node>* > itCand = cliqueList.begin();
while (itCand.valid())
{
//in the case of cliques, the node needs min degree
//greater or equal to current clique size
//TODO: adapt to dense subgraphs
bool isCand = false;
if (m_density == 100)
isCand = (vCand->degree() >= (*itCand)->size());
else isCand = (vCand->degree() >= ceil(m_density*(*itCand)->size()/100.0));
if (isCand)
{
//TODO: insert adjacency oracle here to speed
//up the check?
//TODO: check if change from clique to dense subgraph criterion
//violates some preconditions for our search
if (allAdjacent(vCand, (*itCand)))
{
OGDF_ASSERT(m_usedNode[*itNode] == false)
(*itCand)->pushBack(*itNode);
setFound = true;
m_usedNode[(*itNode)] = true;
//bubble sort the clique after insertion of the node
//while size > predsize swap positions
ListIterator< List<node>* > itSearch = itCand.pred();
if (itSearch.valid())
{
while (itSearch.valid() &&
( (*itCand)->size() > (*itSearch)->size()) )
{
--itSearch;
}
//If valid, move behind itSearch, else move to front
if (!itSearch.valid())
cliqueList.moveToFront(itCand);
else cliqueList.moveToSucc(itCand, itSearch);
}//if valid
break;
}//if node fits into node set
}//if sufficient degree
//hier kann man mit else breaken, wenn Liste immer sortiert ist
++itCand;
}//while clique candidates
//create a new candidate if necessary
if (!setFound)
{
List<node>* cliqueCandidate = OGDF_NEW List<node>();
itCand = cliqueList.pushBack(cliqueCandidate);
OGDF_ASSERT(m_usedNode[*itNode] == false)
cliqueCandidate->pushBack(*itNode);
m_usedNode[(*itNode)] = true;
}//if no candidate yet