本文整理汇总了C++中NodeMap::end方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeMap::end方法的具体用法?C++ NodeMap::end怎么用?C++ NodeMap::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeMap
的用法示例。
在下文中一共展示了NodeMap::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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;
}
}
示例3: 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);
}
示例4: 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));
}
}
示例5: HandleNodeReq
void CKadHandler::HandleNodeReq(const CVariant& NodeReq, CKadNode* pNode, CComChannel* pChannel)
{
if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT"))
LogLine(LOG_DEBUG, L"Recived 'Node Resuest' to %s", pNode->GetID().ToHex().c_str());
CVariant NodeRes;
uint32 uDesiredCount = NodeReq["RCT"];
if(uDesiredCount == 0)
throw CException(LOG_ERROR, L"node requested 0 nodes");
int iMaxState = NodeReq.Get("MNC", NODE_2ND_CLASS);
NodeMap Nodes;
if(!NodeReq.Has("TID"))
GetParent<CKademlia>()->Root()->GetBootstrapNodes(GetParent<CKademlia>()->Root()->GetID(), Nodes, uDesiredCount, pChannel->GetAddress().GetProtocol(), iMaxState);
else
GetParent<CKademlia>()->Root()->GetClosestNodes(NodeReq["TID"], Nodes, uDesiredCount, pChannel->GetAddress().GetProtocol(), iMaxState);
CVariant List;
for(NodeMap::iterator I = Nodes.begin(); I != Nodes.end(); I++)
List.Append(I->second->Store());
NodeRes["LIST"] = List;
if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT"))
LogLine(LOG_DEBUG, L"Sending 'Node Response' to %s", pNode->GetID().ToHex().c_str());
pChannel->QueuePacket(KAD_NODE_RESPONSE, NodeRes);
}
示例6: 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;
}
}
}
示例7: remove
void remove(NetNodeIntern* node) {
NodeMap::iterator f = nodeMap.find(node);
if(f != nodeMap.end()) {
updates.erase(f->second);
nodeMap.erase(f);
}
}
示例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;
}
示例9: 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;
}
}
示例10: 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;
}
}
示例11: 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();
}
示例12: 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;
}
}
示例13: PMap
void PMap(const NodeMap& m)
{
// print out map
NodeMap::const_iterator it;
pout() << "Node map has " << m.size() << " nodes\n";
for (it=m.begin(); it!=m.end(); it++)
{
pout() << "node "; PIV(it->first); pout() << ": " << it->second << "\n";
}
}
示例14: AddNodes
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);
}
}
示例15: MakeCloseTarget
CUInt128 CKademlia::MakeCloseTarget(int *pDistance)
{
if(!m_pKadHandler)
{
if(pDistance)
*pDistance = -1;
return 0;
}
CUInt128 uMyID = m_pRootZone->GetID();
NodeMap Nodes;
m_pRootZone->GetClosestNodes(uMyID, Nodes, Cfg()->GetInt("BucketSize"));
if(Nodes.size() < 2)
{
if(pDistance)
*pDistance = -1;
return 0;
}
// Find Median distance difference between nodes closest to us
vector<CUInt128> Diff;
for(NodeMap::iterator np = Nodes.begin(), n = np++; np != Nodes.end(); n = np++)
Diff.push_back(np->first - n->first);
CUInt128 Sep = Median(Diff);
// generate ID that is closer to us than the closest node by a few difference
CUInt128 uDistance = Nodes.begin()->first;
for(int i=0; i < 3 && uDistance > Sep; i++)
uDistance = uDistance - Sep;
CUInt128 uCloser = uMyID ^ uDistance;
// count the matchign bits
UINT uLevel=0;
for(; uLevel < uMyID.GetBitSize(); uLevel++)
{
if(uCloser.GetBit(uLevel) != uMyID.GetBit(uLevel))
break;
}
// add a few more matching bytes
for(UINT i=0; i < 4 && uLevel < uMyID.GetBitSize() - 1; i++)
{
uCloser.SetBit(uLevel, uMyID.GetBit(uLevel));
uLevel++;
}
if(pDistance)
*pDistance = (int)uMyID.GetBitSize() - uLevel;
// create a random ID that we are closest to
CUInt128 uRandom(uCloser, uLevel);
//wstring sTest = (uMyID ^ uRandom).ToBin();
return uRandom;
}