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


C++ AbstractNode::getChildren方法代码示例

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


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

示例1: isDisjunctionOfComplexConjunctions

bool AbstractNode::isDisjunctionOfComplexConjunctions()
{
    if(AbstractNode::TYPE_OPERATION_OR != getType())
        return false; //not a disjunction

    int numOperations = 0;
    ChainIterator<AbstractNode*> *iterator = children->getIterator();
    while(true == iterator->hasNext()) {
        AbstractNode *child = iterator->next(); //Get an element which might be conjunction

        //Disjunction contains elements which are not parts of conjunction
        if(!((AbstractNode::TYPE_VARIABLE == child->getType()) ||
               (AbstractNode::TYPE_OPERATION_AND == child->getType()) ||
               (AbstractNode::TYPE_OPERATION_NOT == child->getType()))) {
            return false;
        }

        if(AbstractNode::TYPE_OPERATION_AND == child->getType()) {
            if(child->getChildren()->getSize() > 1)
                numOperations++;
        }

        if(AbstractNode::TYPE_OPERATION_NOT == child->getType()) {
            AbstractNode *grandChild = child->getChildren()->getFirstElement();
            if(AbstractNode::TYPE_VARIABLE != grandChild->getType()) {
                return false; //Contains complex NOT operation
            }
        }

    }
    return (numOperations > 0);
}
开发者ID:anubhab91,项目名称:sat-cnf-converter,代码行数:32,代码来源:abstractnode.cpp

示例2: consistsFromSimpleElements

bool AbstractNode::consistsFromSimpleElements()
{
    ChainIterator<AbstractNode*> *iterator = children->getIterator();
    while(true == iterator->hasNext()) {
        AbstractNode *child = iterator->next();
        if(AbstractNode::TYPE_VARIABLE == child->getType())
            continue;
        if(AbstractNode::TYPE_OPERATION_NOT == child->getType()) {
            AbstractNode *notChild = child->getChildren()->getFirstElement();
            if(AbstractNode::TYPE_VARIABLE == notChild->getType())
                continue;
        }
        return false;
    }
    return true;
}
开发者ID:anubhab91,项目名称:sat-cnf-converter,代码行数:16,代码来源:abstractnode.cpp

示例3: computeBestPath

void AStarSearcher::computeBestPath(std::vector<AbstractNode*>& out_path)
{
	std::priority_queue<AbstractNode*, std::vector<AbstractNode*>, AStarPriorityQueueComparer> edgeList;

	AbstractNode* currentNode = m_rootNode;

	while(!currentNode->isEnd())
	{
		currentNode->spawnChildren();
		addExpandedNode();
		const std::vector<AbstractNode*>& children = currentNode->getChildren();

		for(int i = 0; i < children.size(); i++)
		{
			edgeList.push(children[i]);
		}

		if (edgeList.size() == 0)
			break;

		AbstractNode* nextBest = edgeList.top();
		edgeList.pop();

		//if we did not select a child node then we have to go back down and up through the tree
		if(nextBest->getParent() != currentNode)
			goToChild(currentNode, nextBest->getParent());

		currentNode = nextBest;
		currentNode->onEnter();
	}

	if (currentNode->isGoal()) {
		// Award 100 points
		setFinalScore(-currentNode->getTotalCost());
	} else {
		setFinalScore(-currentNode->getTotalCost());
	}

	while(currentNode)
	{
		out_path.insert(out_path.begin(), currentNode);
		currentNode = currentNode->getParent();
	}
}
开发者ID:Samee-Swartz,项目名称:SuperSecretProject,代码行数:44,代码来源:AStarSearcher.cpp


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