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


C++ NodeRefPtr::end方法代码示例

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


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

示例1: SearchResult

SearchResult
Tree::find(NodeRefPtr startNode, const ResourceName &policyRes,
	   bool usePatterns = true) {
    am_resource_match_t compRes;
    std::list<NodeRefPtr>::const_iterator iter;

    const ResourceName& resName = startNode->getPolicyDecision()->getName();
    compRes = compare(resName, policyRes, usePatterns);

    if(compRes != AM_SUB_RESOURCE_MATCH && compRes != AM_EXACT_PATTERN_MATCH) {
	if(compRes == AM_EXACT_MATCH)
	    return SearchResult(AM_EXACT_MATCH, startNode);
	return SearchResult(compRes, Node::NULL_NODE);
    }

    for(iter = startNode->begin(); iter != startNode->end(); ++iter) {
	NodeRefPtr node = *iter;
	const PDRefCntPtr &element = node->getPolicyDecision();
	switch((compare(element->getName(), policyRes, usePatterns))) {
	case AM_EXACT_MATCH:
	    return SearchResult(AM_EXACT_MATCH, node);
	    break;
	case AM_NO_MATCH:
	    continue;
	    break;
	case AM_SUPER_RESOURCE_MATCH:
	    return SearchResult(AM_SUB_RESOURCE_MATCH, startNode);
	case AM_SUB_RESOURCE_MATCH:
	case AM_EXACT_PATTERN_MATCH:
	    {
		SearchResult result = find(node, policyRes, usePatterns);
		switch(result.first) {
		    // In case of the node below returns SUB_RESOURCE_MATCH,
		    // EXACT_PATTERN_MATCH or EXACT_MATCH,
		    // we just need to pass on the result upwards.
		case AM_SUB_RESOURCE_MATCH:
		case AM_EXACT_PATTERN_MATCH:
		case AM_EXACT_MATCH:
		    // Bingo! got a match.
		    return result;
		case AM_SUPER_RESOURCE_MATCH:
		case AM_NO_MATCH:
		    return SearchResult(AM_SUB_RESOURCE_MATCH, startNode);
		}
	    }
	    break;
	}
    }

    // This is the level we have to add the node.
    if(iter == startNode->end()) {
	if(compRes == AM_SUB_RESOURCE_MATCH || compRes == AM_EXACT_PATTERN_MATCH)
	    return SearchResult(compRes, startNode);
	else
	    return SearchResult(compRes, Node::NULL_NODE);
    }
    return SearchResult(AM_NO_MATCH, Node::NULL_NODE);
}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例2: compare

void
Tree::search_recursive(const ResourceName &resName,
		       const NodeRefPtr node,
		       std::vector<PDRefCntPtr> &results,
		       bool usePatterns) const {

    am_resource_match_t compRes;
    compRes = compare(node->getPolicyDecision()->getName(),
		      resName,
		      usePatterns);

    std::list<NodeRefPtr>::const_iterator iter;
    switch(compRes) {
    case AM_EXACT_MATCH:
	results.push_back(node->getPolicyDecision());
	break;
    case AM_EXACT_PATTERN_MATCH:
	results.push_back(node->getPolicyDecision());
	// fall through to the following
    case AM_SUB_RESOURCE_MATCH:
    case AM_NO_MATCH:
	for(iter = node->begin(); iter != node->end(); iter++) {
	    search_recursive(resName, *iter, results, usePatterns);
	}
	break;
    default:
	break;
    }
    return;
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例3: newNode

bool
Tree::insertBelow(NodeRefPtr parent, PDRefCntPtr &elem) {
    std::list<NodeRefPtr>::iterator iter;
    NodeRefPtr newNode(new Node(parent, elem));

    // add the subordinate nodes of newNode under
    // new node.  In the next loop, we iterate nodes
    // under new node and remove them from parent.
    // Reason: if we remove nodes under parent in this
    // loop, iterator becomes invalid.
    ScopeLock myLock(treeLock);
    for(iter = parent->begin(); iter != parent->end(); iter++) {
	NodeRefPtr node = *iter;
	PDRefCntPtr data = node->getPolicyDecision();
	switch(compare(data->getName(), elem->getName(), false)) {
	case AM_EXACT_MATCH:
	case AM_SUB_RESOURCE_MATCH:
	    return false;

	case AM_NO_MATCH:
	    break;
	case AM_SUPER_RESOURCE_MATCH:
	    newNode->addNode(node);
	    break;
	}
    }

    for(iter = newNode->begin(); iter != newNode->end(); iter++) {
	NodeRefPtr node = *iter;
	parent->remove(node);
    }

    parent->addNode(newNode);

    return true;
}
开发者ID:,项目名称:,代码行数:36,代码来源:


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