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


C++ Proxy::setDepth方法代码示例

本文整理汇总了C++中Proxy::setDepth方法的典型用法代码示例。如果您正苦于以下问题:C++ Proxy::setDepth方法的具体用法?C++ Proxy::setDepth怎么用?C++ Proxy::setDepth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Proxy的用法示例。


在下文中一共展示了Proxy::setDepth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newnode

int
DepthFirstHillClimbSearch(List<NodeType> &startstatelist, 
		BinaryTree_AVL<DataType> &startlist, 
		BinaryTree_AVL<DataType> &otherlist)
{
	int status;

	// track all states created
	BinaryTree_AVL<String> allstates;

	// create open stack for traversal
	List<Proxy<NodeType> > openstack;

	// keep track of current path here instead of 
	// using parent pointers. parent pointers cause
	// cycles and reference-counted pointers cannot
	// deal with cyclic data structures. they cause
	// major memory leaks.
	//
	int nodedepth = 1;
	List<Proxy<NodeType> > currentpath;

	// copy list of start states
	ListIterator<NodeType> startstateIter(startstatelist);
	for ( ; !startstateIter.done(); startstateIter++)
	{
		// copy start state
		Proxy<NodeType> pstart(startstateIter());

		// calculate the heuristic value for this node
		if ((status = pstart->heuristic(startlist, otherlist)) != OK)
		{
			ERRORD("heuristic() failed.", status, errno);
			return(status);
		}

		// set start node depth
		pstart->setDepth(nodedepth);

		// insert start state into open queue
		if ((status = openstack.insertOrdered(pstart)) != OK)
		{
			ERRORD("insertOrdered() failed.", status, errno);
			return(status);
		}
	}

	// children priority queue
	List<Proxy<NodeType> > childpq;
	
	// start search loop
	int olddepth = nodedepth;
	Proxy<NodeType> pchild;
	for (Proxy<NodeType> pnode; ! openstack.isEmpty(); )
	{
		// remove next node from priority open queue
		if ((status = openstack.removeAtFront(pnode)) != OK)
		{
			ERRORD("removeAtFront() failed.", status, errno);
			return(status);
		}

		// check if we have a goal node or not
		status = pnode->isGoal(startlist, otherlist);
		switch (status)
		{
		case OK:
			// update current path
			if ((status = updatepath(nodedepth, 
				olddepth, pnode, currentpath)) != OK)
				return(status);
			break;

		case NOMATCH:
		case MAXDEPTHEXCEEDED:
			// no clauses were generated. skip further
			// processing of this node.
			continue;

		case VALID:
			// update current path
			if ((status = updatepath(nodedepth, 
				olddepth, pnode, currentpath)) != OK)
				return(status);

			// goal node, print solution
			PrintSolution(pnode);
			PrintSolution(currentpath);
			PrintRenameVariables(pnode);

			// check if more than one solutions is required
			solutionsfound += 1;
			statistics[SolutionsFound] += 1;
			totalstatistics[TotalSolutionsFound] += 1;
			if (solutionsfound >= solutionsrequired)
				return(VALID);
			continue;

		case MAXCLAUSEEXCEEDED:
			// check if any solutions were found
//.........这里部分代码省略.........
开发者ID:ombt,项目名称:ombt,代码行数:101,代码来源:search.cpp


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