当前位置: 首页>>代码示例>>C++>>正文


C++ ListIterator::pred方法代码示例

本文整理汇总了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;
		}
	}
}
开发者ID:lncosie,项目名称:ogdf,代码行数:41,代码来源:RadialTreeLayout.cpp

示例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
开发者ID:lncosie,项目名称:ogdf,代码行数:66,代码来源:CliqueFinder.cpp


注:本文中的ListIterator::pred方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。