Guest User

Untitled

a guest
Jun 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. (*foo)[index] = bar;
  2.  
  3. foo->insert(std::pair<KeyType,ValueType>(myKey, myValue));
  4.  
  5. ...
  6. typedef std::map<int, SCNode*> SCNodeMap;
  7. ...
  8.  
  9.  
  10. void StemAndCycle::getCycleNodes(SCNodeMap* cycleNodes)
  11. {
  12. (*cycleNodes)[root->getId()] = root;
  13.  
  14. SCNode* tmp = root->getSucc();
  15. while(tmp->getId() != root->getId())
  16. {
  17. // (*cycleNodes)[tmp->getId()] == tmp; // crashes (in loop below)
  18. cycleNodes->insert(std::pair<int, SCNode*>(tmp->getId(), tmp));//OK
  19. std::pair<int, SCNode*> it = *(cycleNodes->find(tmp->getId()));
  20. tmp = tmp->getSucc();
  21. }
  22.  
  23. // debugging; print ids of all the SCNode objects in the collection
  24. std::map<int, SCNode*>::iterator it = cycleNodes->begin();
  25. while(it != cycleNodes->end())
  26. {
  27. std::pair<int, SCNode*> p = (*it);
  28. SCNode* tmp = (*it).second; // null except for it = cycleNodes->begin()
  29. std::cout << "tmp node id: "<<tmp->getId()<<std::endl;
  30. it++;
  31. }
  32.  
  33. }
  34.  
  35. (*cycleNodes)[tmp->getId()] == tmp;
  36.  
  37. (*cycleNodes)[tmp->getId()] = tmp;
  38.  
  39. if ( amap[x] == 42 ) {
  40. ...
  41. }
Add Comment
Please, Sign In to add comment