本文整理汇总了C++中Proxy::getChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ Proxy::getChildren方法的具体用法?C++ Proxy::getChildren怎么用?C++ Proxy::getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Proxy
的用法示例。
在下文中一共展示了Proxy::getChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newnode
int
BreadthFirstSearch(List<NodeType> &startstatelist,
BinaryTree_AVL<DataType> &startlist,
BinaryTree_AVL<DataType> &otherlist)
{
int status;
// track all states created
BinaryTree_AVL<String> allstates;
// create open priority queue
List<Proxy<NodeType> > openpq;
// copy list of start states
int nodedepth = 1;
ListIterator<NodeType> startstateIter(startstatelist);
for ( ; !startstateIter.done(); startstateIter++)
{
// copy start state
Proxy<NodeType> pstart(startstateIter());
// set start node depth
pstart->setDepth(nodedepth);
// insert start state into open queue
if ((status = openpq.insertAtEnd(pstart)) != OK)
{
ERRORD("insertAtFront() failed.", status, errno);
return(status);
}
}
// start search loop
for (Proxy<NodeType> pnode; ! openpq.isEmpty(); )
{
// remove next node from priority open queue
if ((status = openpq.removeAtFront(pnode)) != OK)
{
ERRORD("removeAtFront() failed.", status, errno);
return(status);
}
// set current node depth
nodedepth = pnode->getDepth();
// check if we have a goal node or not
status = pnode->isGoal(startlist, otherlist);
switch (status)
{
case OK:
break;
case NOMATCH:
case MAXDEPTHEXCEEDED:
// no clauses were generated. skip further
// processing of this node.
continue;
case VALID:
// goal node, print solution
PrintSolution(pnode);
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
if (solutionsfound > 0)
return(VALID);
else
return(NOTPROVEN);
default:
// some type of error
ERRORD("isGoal() failed.", status, errno);
return(status);
}
// generate the children of the current node
if ((status = pnode->expand(startlist, otherlist)) != OK)
{
ERRORD("expand() failed.", status, errno);
return(status);
}
// set up links to parent and calculate the heuristic value
ListIterator<Proxy<NodeType> >
childrenIter(*pnode->getChildren());
for ( ; !childrenIter.done(); childrenIter++)
{
// pointer to child
Proxy<NodeType> pchild(childrenIter());
// set up link to parent
//.........这里部分代码省略.........
示例2: if
int
dfs(Proxy<NodeType> &pnode, int &threshold, int &next_threshold,
BinaryTree_AVL<DataType> &startlist,
BinaryTree_AVL<DataType> &otherlist)
{
int status;
// expand the current node's children
if ((status = pnode->expand(startlist, otherlist)) != OK)
{
// some type of error
ERRORD("expand() failed.", status, errno);
return(status);
}
// scan children for goal nodes
ListIterator<Proxy<NodeType> > childrenIter(*pnode->getChildren());
for ( ; !childrenIter.done(); childrenIter++)
{
// get pointer to child
Proxy<NodeType> pchild(childrenIter());
// set up link to parent
if (reporttype == ReportParent ||
reporttype == ReportBoth)
pchild->setParent(pnode);
// calculate the heuristic value
if ((status = pchild->heuristic(startlist, otherlist)) != OK)
{
ERRORD("heuristic() failed.", status, errno);
return(status);
}
// check if we have a goal node
status = pchild->isGoal(startlist, otherlist);
switch (status)
{
case OK:
break;
case NOMATCH:
case MAXDEPTHEXCEEDED:
continue;
case MAXCLAUSEEXCEEDED:
return(status);
case VALID:
// goal node, print solution
PrintSolution(pnode);
PrintRenameVariables(pnode);
return(VALID);
default:
// some type of error
ERRORD("isGoal() failed.", status, errno);
return(status);
}
// check if we continue, is threshold exceeded?
int childcost = pchild->getFvalue();
if (childcost <= threshold)
{
// continue depth-first search
status = dfs(pchild, threshold, next_threshold,
startlist, otherlist);
switch (status)
{
case OK:
case NOMATCH:
case MAXDEPTHEXCEEDED:
case NOTPROVEN:
break;
case MAXCLAUSEEXCEEDED:
return(MAXCLAUSEEXCEEDED);
case VALID:
// goal node, print solution
return(VALID);
default:
// some type of error
ERRORD("dfs() failed.", status, errno);
return(status);
}
}
else if (childcost < next_threshold)
{
next_threshold = childcost;
}
}
// goal was not not proven
return(NOTPROVEN);
}