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


C++ NodeMap类代码示例

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


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

示例1: LogLine

void CKadHandler::HandleNodeRes(const CVariant& NodeRes, CKadNode* pNode, CComChannel* pChannel)
{
	if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT"))
		LogLine(LOG_DEBUG, L"Recived 'Node Response' from %s", pNode->GetID().ToHex().c_str());

	CVariant List = NodeRes["LIST"];
	if(List.Count() > (uint32)GetParent<CKademlia>()->Cfg()->GetInt("NodeReqCount"))
		throw CException(LOG_ERROR, L"Node returned more nodes than requested (spam)");
	
	SKadData* pData = pChannel->GetData<SKadData>();
	// Note: if pData->pLookup is NULL this was just a bootstrap request

	NodeMap Nodes;
	for(uint32 i = 0; i<List.Count(); i++)
	{
		CPointer<CKadNode> pNewNode = new CKadNode(GetParent<CKademlia>()->Root());
		pNewNode->Load(List.At(i));
		if(GetParent<CKademlia>()->Root()->AddNode(pNewNode) && pData->pLookup)
		{
			CUInt128 uDistance = pData->pLookup->GetID() ^ pNewNode->GetID();
			Nodes.insert(NodeMap::value_type(uDistance, pNewNode));
		}
	}

	if(pData->pLookup)
		GetParent<CKademlia>()->Manager()->AddNodes(pData->pLookup, pNode, pChannel, Nodes);
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:27,代码来源:KadHandler.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: 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

示例4: UpdateParticlesAfterReMesh

void NodeBasedCellPopulation<DIM>::UpdateMapsAfterRemesh(NodeMap& map)
{
    if (!map.IsIdentityMap())
    {
        UpdateParticlesAfterReMesh(map);

        // Update the mappings between cells and location indices
        ///\todo we want to make mCellLocationMap private - we need to find a better way of doing this
        std::map<Cell*, unsigned> old_map = this->mCellLocationMap;

        // Remove any dead pointers from the maps (needed to avoid archiving errors)
        this->mLocationCellMap.clear();
        this->mCellLocationMap.clear();

        for (std::list<CellPtr>::iterator it = this->mCells.begin();
             it != this->mCells.end();
             ++it)
        {
            unsigned old_node_index = old_map[(*it).get()];

            // This shouldn't ever happen, as the cell vector only contains living cells
            assert(!map.IsDeleted(old_node_index));

            unsigned new_node_index = map.GetNewIndex(old_node_index);
            this->SetCellUsingLocationIndex(new_node_index,*it);
        }

        this->Validate();
    }
}
开发者ID:getshameer,项目名称:Chaste,代码行数:30,代码来源:NodeBasedCellPopulation.cpp

示例5: clone

Model::Ptr Model::clone(const std::string& newname) const
{
	NodeMap map;

	Model::Ptr result(new Model());
	if (newname.empty()) {
		result->id = id;
	}
	else {
		result->id = newname;
	}

	result->root = root->clone(map); //this populates map with Old Node -> New Node entries

	for (Controller *obj: controllers) {
		result->addController(obj->clone(map));
	}
	for (Renderable *obj: renderables) {
		result->addRenderable(obj->clone(map));
	}
	for (const auto& entry: nodes) {
		result->addNamedNode(entry.first, map.get(entry.second));
	}

	result->shape = shape;
	
	return result;
}
开发者ID:btdavis,项目名称:MWEngine,代码行数:28,代码来源:model.cpp

示例6: builder

ExpressionPtr IclHostPlugin::PostVisit(const clang::Expr* expr, const insieme::core::ExpressionPtr& irExpr,
                                               insieme::frontend::conversion::Converter& convFact) {
	NodeManager& mgr = irExpr->getNodeManager();
	IRBuilder builder(mgr);
	const core::lang::BasicGenerator& gen = builder.getLangBasic();
		iclRunKernel = irp::callExpr(pattern::any, irp::literal("icl_run_kernel"),
				var("derefKernel", irp::callExpr(pattern::any, pattern::atom(gen.getRefDeref()), pattern::single(var("kernel", pattern::any)))) <<
				*pattern::any << irp::callExpr(pattern::any, pattern::atom(gen.getVarlistPack()),
				pattern::single(irp::tupleExpr(pattern::any << irp::expressions(*var("args", pattern::any))))));

	core::pattern::TreePattern derefOfIclBuffer = irp::callExpr(pattern::atom(builder.refType(
																					builder.arrayType(builder.genericType("_icl_buffer")))),
																					pattern::atom(gen.getRefDeref()), 
																					pattern::single(var("buffer", pattern::any)));


	NodeMap replacements;
	irp::matchAllPairs(iclRunKernel, irExpr, [&](const NodePtr& matchPtr, const NodeMatch& runKernel) {

		// remove deref from buffers
		for(NodePtr arg : runKernel["args"].getFlattened()) {
			MatchOpt match = derefOfIclBuffer.matchPointer(arg);
			if(match) {
				replacements[match.get().getRoot()] = match.get()["buffer"].getValue();
			}
		}
	});
	if(!replacements.empty())
		return transform::replaceAll(mgr, irExpr, replacements).as<ExpressionPtr>();

	return irExpr;
}
开发者ID:alcides,项目名称:insieme,代码行数:32,代码来源:ocl_host_extension.cpp

示例7: 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

示例8: 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

示例9: domNodesPerDocument

DOMNode* ScriptInterpreter::getDOMNodeForDocument(Document* document, Node* node)
{
    if (!document)
        return static_cast<DOMNode*>(domObjects().get(node));
    NodeMap* documentDict = domNodesPerDocument().get(document);
    if (documentDict)
        return documentDict->get(node);
    return NULL;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:9,代码来源:kjs_binding.cpp

示例10: prepForTree

    static void prepForTree() {
#ifndef VL_LEAK_CHECKS
	s_nodes.clear();
#endif
	for (NodeMap::iterator it = s_nodes.begin(); it != s_nodes.end(); ++it) {
	    it->second &= ~FLAG_IN_TREE;
	    it->second &= ~FLAG_LINKABLE;
	}
    }
开发者ID:mballance,项目名称:verilator,代码行数:9,代码来源:V3Broken.cpp

示例11: 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

示例12: 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

示例13: 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

示例14: SLookupNode

void CLookupHistory::AddNodes(const NodeMap& Nodes, const CUInt128& ByID)
{
	for(NodeMap::const_iterator I = Nodes.begin(); I != Nodes.end(); I++)
	{
		LookupNodeMap::iterator J = m_Nodes.find(I->second->GetID());
		if(J == m_Nodes.end())
			J = m_Nodes.insert(LookupNodeMap::value_type(I->second->GetID(), SLookupNode())).first;
		J->second.FoundByIDs.push_back(ByID == 0 ? SELF_NODE : ByID);
	}
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:10,代码来源:LookupHistory.cpp

示例15: 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


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