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


C++ NodeMap::find方法代码示例

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


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

示例1: mirrorEdge

HLink MLGDao::mirrorEdge( const HLink& current, Direction dir, const Layer& newLayer, NodeMap& nodeMap )
{
    // Find equivalent in top layer
    Node topSrc;
    auto it = nodeMap.find(current.source());
    if( it != nodeMap.end() ) { // not found
        topSrc = it->second;
    }
    else {
        topSrc = mirrorNode(current.source(), dir, newLayer);
        nodeMap.emplace(current.source(), topSrc);
    }

    Node topTgt;
    it = nodeMap.find(current.target());
    if( it != nodeMap.end() ) { // not found
        topTgt = it->second;
    }
    else {
        topTgt = mirrorNode(current.target(), dir, newLayer);
        // Add to map to retrieve edges
        nodeMap.emplace(current.target(), topTgt);
    }
    // Add new HLink
    return m_link->addHLink(topSrc.id(), topTgt.id(), current.weight());
}
开发者ID:caomw,项目名称:mld,代码行数:26,代码来源:MLGDao.cpp

示例2: addInTree

    static void addInTree(AstNode* nodep, bool linkable) {
#ifndef VL_LEAK_CHECKS
	if (!linkable) return;  // save some time, else the map will get huge!
#endif
	NodeMap::iterator iter = s_nodes.find(nodep);
	if (iter == s_nodes.end()) {
#ifdef VL_LEAK_CHECKS
	    nodep->v3fatalSrc("AstNode is in tree, but not allocated\n");
#endif
	} else {
	    if (!(iter->second & FLAG_ALLOCATED)) {
#ifdef VL_LEAK_CHECKS
		nodep->v3fatalSrc("AstNode is in tree, but not allocated\n");
#endif
	    }
	    if (iter->second & FLAG_IN_TREE) {
		nodep->v3fatalSrc("AstNode is already in tree at another location\n");
	    }
	}
	int or_flags = FLAG_IN_TREE | (linkable?FLAG_LINKABLE:0);
	if (iter == s_nodes.end()) {
	    s_nodes.insert(make_pair(nodep,or_flags));
	} else {
	    iter->second |= or_flags;
	}
    }
开发者ID:mballance,项目名称:verilator,代码行数:26,代码来源:V3Broken.cpp

示例3: MakePowerLine

void UtilOSMVisitor::MakePowerLine()
{
	m_line = m_util_layer->AddNewLine();

	m_line->m_poles.resize(m_refs.size());
	for (uint r = 0; r < m_refs.size(); r++)
	{
		int idx = m_refs[r];

		// Look for that node by id; if we don't find it, then it wasn't a tower;
		// it was probably a start or end point at a non-tower feature.
		NodeMap::iterator it = m_nodes.find(m_id);
		if (it != m_nodes.end())
		{
			// Connect to a known pole.
			m_line->m_poles[r] = m_nodes[idx].pole;
		}
		else
		{
			// We need to make a new pole node.
			OSMNode &node = m_nodes[idx];

			m_pole = m_util_layer->AddNewPole();
			m_pole->m_id = idx;
			m_pole->m_p = node.p;

			node.pole = m_pole;

			// Then we can connect it
			m_line->m_poles[r] = m_pole;
		}
	}
}
开发者ID:kamalsirsa,项目名称:vtp,代码行数:33,代码来源:UtilityMap.cpp

示例4: remove

		void remove(NetNodeIntern* node) {
			NodeMap::iterator f = nodeMap.find(node);
			if(f != nodeMap.end()) {
				updates.erase(f->second);
				nodeMap.erase(f);
			}
		}
开发者ID:iamnilay3,项目名称:openlierox,代码行数:7,代码来源:netstream.cpp

示例5: okIfBelow

    static bool okIfBelow(const AstNode* nodep) {
	// Must be linked to and below current node
	if (!okIfLinkedTo(nodep)) return false;
	NodeMap::iterator iter = s_nodes.find(nodep);
	if (iter == s_nodes.end()) return false;
	if (!(iter->second & FLAG_UNDER_NOW)) return false;
	return true;
    }
开发者ID:mballance,项目名称:verilator,代码行数:8,代码来源:V3Broken.cpp

示例6: setUnder

    static void setUnder(const AstNode* nodep, bool flag) {
	// Called by BrokenCheckVisitor when each node entered/exited
	if (!okIfLinkedTo(nodep)) return;
	NodeMap::iterator iter = s_nodes.find(nodep);
	if (iter!=s_nodes.end()) {
	    iter->second &= ~FLAG_UNDER_NOW;
	    if (flag) iter->second |=  FLAG_UNDER_NOW;
	}
    }
开发者ID:mballance,项目名称:verilator,代码行数:9,代码来源:V3Broken.cpp

示例7: deleted

    // METHODS
    static void deleted(const AstNode* nodep) {
	// Called by operator delete on any node - only if VL_LEAK_CHECKS
	if (debug()>=9) cout<<"-nodeDel:  "<<(void*)(nodep)<<endl;
	NodeMap::iterator iter = s_nodes.find(nodep);
	if (iter==s_nodes.end() || !(iter->second & FLAG_ALLOCATED)) {
	    ((AstNode*)(nodep))->v3fatalSrc("Deleting AstNode object that was never tracked or already deleted\n");
	}
	if (iter!=s_nodes.end()) s_nodes.erase(iter);
    }
开发者ID:mballance,项目名称:verilator,代码行数:10,代码来源:V3Broken.cpp

示例8: recursiveTopSort

Status InitializerDependencyGraph::recursiveTopSort(
    const NodeMap& nodeMap,
    const Node& currentNode,
    std::vector<std::string>* inProgressNodeNames,
    stdx::unordered_set<std::string>* visitedNodeNames,
    std::vector<std::string>* sortedNames) {

    /*
     * The top sort is performed by depth-first traversal starting at each node in the
     * dependency graph, short-circuited any time a node is seen that has already been visited
     * in any traversal.  "visitedNodeNames" is the set of nodes that have been successfully
     * visited, while "inProgressNodeNames" are nodes currently in the exploration chain.  This
     * structure is kept explicitly to facilitate cycle detection.
     *
     * This function implements a depth-first traversal, and is called once for each node in the
     * graph by topSort(), above.
     */

    if ((*visitedNodeNames).count(currentNode.first))
        return Status::OK();

    inProgressNodeNames->push_back(currentNode.first);

    auto firstOccurence =
        std::find(inProgressNodeNames->begin(), inProgressNodeNames->end(), currentNode.first);
    if (std::next(firstOccurence) != inProgressNodeNames->end()) {
        sortedNames->clear();
        std::copy(firstOccurence, inProgressNodeNames->end(), std::back_inserter(*sortedNames));
        std::ostringstream os;
        os << "Cycle in dependendcy graph: " << sortedNames->at(0);
        for (size_t i = 1; i < sortedNames->size(); ++i)
            os << " -> " << sortedNames->at(i);
        return Status(ErrorCodes::GraphContainsCycle, os.str());
    }

    for (const auto& prereq : currentNode.second.prerequisites) {
        auto nextNode = nodeMap.find(prereq);
        if (nextNode == nodeMap.end()) {
            std::ostringstream os;
            os << "Initializer " << currentNode.first << " depends on missing initializer "
               << prereq;
            return {ErrorCodes::BadValue, os.str()};
        }

        Status status = recursiveTopSort(
            nodeMap, *nextNode, inProgressNodeNames, visitedNodeNames, sortedNames);
        if (Status::OK() != status)
            return status;
    }
    sortedNames->push_back(currentNode.first);
    if (inProgressNodeNames->back() != currentNode.first)
        return Status(ErrorCodes::InternalError, "inProgressNodeNames stack corrupt");
    inProgressNodeNames->pop_back();
    visitedNodeNames->insert(currentNode.first);
    return Status::OK();
}
开发者ID:EvgeniyPatlan,项目名称:percona-server-mongodb,代码行数:56,代码来源:initializer_dependency_graph.cpp

示例9: pushUpdate

		void pushUpdate(const DataPackage& p) {
			NodeMap::iterator f = nodeMap.find(p.node.get());
			if(f != nodeMap.end()) {
				*f->second = p;
			}
			else {
				updates.push_back(p);
				Updates::iterator& last = nodeMap[p.node.get()] = updates.end(); --last;
			}
		}
开发者ID:iamnilay3,项目名称:openlierox,代码行数:10,代码来源:netstream.cpp

示例10: okIfLinkedTo

    static bool okIfLinkedTo(const AstNode* nodep) {
	// Someone has a pointer to this node.  Is it kosher?
	NodeMap::iterator iter = s_nodes.find(nodep);
	if (iter == s_nodes.end()) return false;
#ifdef VL_LEAK_CHECKS
	if (!(iter->second & FLAG_ALLOCATED)) return false;
#endif
	if (!(iter->second & FLAG_IN_TREE)) return false;
	if (!(iter->second & FLAG_LINKABLE)) return false;
	return true;
    }
开发者ID:mballance,项目名称:verilator,代码行数:11,代码来源:V3Broken.cpp

示例11: addNewed

    static void addNewed(const AstNode* nodep) {
	// Called by operator new on any node - only if VL_LEAK_CHECKS
	if (debug()) cout<<"-nodeNew:  "<<(void*)(nodep)<<endl;
	NodeMap::iterator iter = s_nodes.find(nodep);
	if (iter!=s_nodes.end() || (iter->second & FLAG_ALLOCATED)) {
	    ((AstNode*)(nodep))->v3fatalSrc("Newing AstNode object that is already allocated\n");
	}
	if (iter == s_nodes.end()) {
	    s_nodes.insert(make_pair(nodep,FLAG_ALLOCATED));
	}
    }
开发者ID:torc-isi,项目名称:torc,代码行数:11,代码来源:V3Broken.cpp

示例12: prune_unchanged_wrappers

void prune_unchanged_wrappers(xmlNodePtr node, NodeMap & nmap)
{
	if (node == nullptr)
		return;

	if (node->type != XML_ENTITY_REF_NODE)
	{
		for (xmlNodePtr child = node->children; child != nullptr; child = child->next)
			prune_unchanged_wrappers(child, nmap);
	}

	if (node->_private != nullptr)
	{
		const NodeMap::iterator pos = nmap.find(reinterpret_cast<ePub3::xml::Node*>(node->_private));
		if (pos != nmap.end())
		{
			if (pos->second == node->type)
				nmap.erase(pos);
			else
				node->_private = nullptr;
		}
	}

	switch (node->type)
	{
	case XML_DTD_NODE:
	case XML_ATTRIBUTE_NODE:
	case XML_ELEMENT_DECL:
	case XML_ATTRIBUTE_DECL:
	case XML_ENTITY_DECL:
	case XML_DOCUMENT_NODE:
		return;
	default:
		break;
	}

	for (xmlAttrPtr attr = node->properties; attr != nullptr; attr = attr->next) {
		find_wrappers(reinterpret_cast<xmlNodePtr>(attr), nmap);
	}
}
开发者ID:Hasimir,项目名称:readium-sdk,代码行数:40,代码来源:document_win.cpp

示例13: UndirectedGraphNode

// Solution 2
// BFS
UndirectedGraphNode* cloneGraph2(UndirectedGraphNode *node) {
    NodeMap book;
    queue<UndirectedGraphNode*> que;
    book[node] = new UndirectedGraphNode(node->label);
    if (!node)
        return NULL;
    que.push(node);
    while (!que.empty()) {
        auto iter = que.front();
        que.pop();
        for (auto nbr : iter->neighbors) {
            if (book.find(nbr) != book.end())
                book[iter]->neighbors.push_back(book[nbr]);
            else {
                UndirectedGraphNode* new_node = new UndirectedGraphNode(iter->label);
                book[nbr] = new_node;
                book[iter]->neighbors.push_back(new_node);
                que.push(nbr);
            }
        }
        
    }
}
开发者ID:vastin,项目名称:codearena,代码行数:25,代码来源:clone-graph.cpp

示例14: outfile


//.........这里部分代码省略.........
                    n3.type==Node::VALID && n4.type==Node::VALID )
                    elements.insert(Element(n1,n2,n3,n4));
#else
                const IntVect& ivu = IntVect(iv).shift(BoxLib::BASISV(2));
                const Node& n1 = ifab(iv ,0);
                const Node& n2 = ifab(IntVect(iv ).shift(BoxLib::BASISV(0)),0);
                const Node& n3 = ifab(IntVect(iv ).shift(BoxLib::BASISV(0)).shift(BoxLib::BASISV(1)),0);
                const Node& n4 = ifab(IntVect(iv ).shift(BoxLib::BASISV(1)),0);
                const Node& n5 = ifab(ivu,0);
                const Node& n6 = ifab(IntVect(ivu).shift(BoxLib::BASISV(0)),0);
                const Node& n7 = ifab(IntVect(ivu).shift(BoxLib::BASISV(0)).shift(BoxLib::BASISV(1)),0);
                const Node& n8 = ifab(IntVect(ivu).shift(BoxLib::BASISV(1)),0);
                if (n1.type==Node::VALID && n2.type==Node::VALID &&
                    n3.type==Node::VALID && n4.type==Node::VALID &&
                    n5.type==Node::VALID && n6.type==Node::VALID &&
                    n7.type==Node::VALID && n8.type==Node::VALID )
                    elements.insert(Element(n1,n2,n3,n4,n5,n6,n7,n8));
#endif
            }
        }
    }

    int nElts = (connect_cc ? elements.size() : nodeMap.size());
    std::cerr << "Before connData allocated " << elements.size() << " elements"  << endl;
    Array<int> connData(MYLEN*nElts);
    std::cerr << "After connData allocated " << elements.size() << " elements" << endl;

    if (connect_cc) {
        cnt = 0;
        for (EltSet::const_iterator it = elements.begin(); it!=elements.end(); ++it)
        {
            for (int j=0; j<MYLEN; ++j)
            {
                const NodeMap::const_iterator noit = nodeMap.find(*((*it).n[j]));
                if (noit == nodeMap.end())
                {
                    std::cout << "Node not found in node map" << std::endl;
                    std::cout << *((*it).n[j]) << std::endl;
                }
                else
                {
                    connData[cnt++] = noit->second+1;
                }
            }
        }
    } else {
        cnt = 1;
        for (int i=0; i<nElts; ++i) {
            for (int j=0; j<MYLEN; ++j) {
                connData[i*MYLEN+j] = cnt++;
            }
        }
    }

    std::cerr << "Final elements built" << endl;

    // Invert the map
    std::vector<Node> nodeVect(nodeMap.size());
    for (NodeMap::const_iterator it=nodeMap.begin(); it!=nodeMap.end(); ++it)
    {
        if (it->second>=nodeVect.size() || it->second<0)
            std::cout << "Bad id: " << it->second << "  bad node: " << it->first << std::endl;
        BL_ASSERT(it->second>=0);
        BL_ASSERT(it->second<nodeVect.size());
        nodeVect[it->second] = (*it).first;
    }
开发者ID:dwillcox,项目名称:BoxLib,代码行数:67,代码来源:AmrDeriveTecplot.cpp


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