本文整理汇总了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
//.........这里部分代码省略.........