Guest User

Untitled

a guest
Mar 25th, 2016
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <map>
  2.  
  3. std::map<std::string, int> relation_map;
  4.  
  5. void setRelationState(std::string guid, int rel){
  6.     for (std::map<std::string, int>::iterator pos = relation_map.begin(); pos != relation_map.end(); pos++)
  7.     {
  8.         if (pos->first.compare(guid) == 0){
  9.             pos->second = rel;
  10.             return;
  11.         }
  12.     }
  13.     relation_map.insert(pair<std::string, int>(guid, rel));
  14. }
  15. int getRelationState(std::string guid){
  16.     for (std::map<std::string, int>::iterator pos = relation_map.begin(); pos != relation_map.end(); pos++)
  17.     {
  18.         if (pos->first.compare(guid) == 0){
  19.             return pos->second;
  20.         }
  21.     }
  22.     return 1;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment