Advertisement
Guest User

Untitled

a guest
Jan 13th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <boost/unordered_map.hpp>
  5.  
  6. int main()
  7. {
  8.     boost::unordered_map<int, std::vector<std::string> > map;
  9.  
  10.         std::cout << "Usage without any initialization:\n";
  11.         std::cout << map[0].size() << "\n\n";
  12.    
  13.     map[1].push_back("qwerty");
  14.         std::cout << "Insertion with non-existing key\n";
  15.         std::cout << map[1].size() << " " << map[1][0] << "\n\n";
  16.    
  17.     map[1].push_back("asdfgh");
  18.         std::cout << "Insertion with existing key\n";
  19.         std::cout << map[1].size() << " " << map[1][0] << " " << map[1][1] << "\n\n";
  20.    
  21.     map[0] = map[1];
  22.         std::cout << "Overwriting of existing key\n";
  23.         std::cout << map[0].size() << " " << map[0][0] << " " << map[0][1] << "\n\n";
  24.  
  25.     return 0;
  26. }
  27. /*
  28. Output:
  29.  
  30. Usage without any initialization:
  31. 0
  32.  
  33. Insertion with non-existing key
  34. 1 qwerty
  35.  
  36. Insertion with existing key
  37. 2 qwerty asdfgh
  38.  
  39. Overwriting of existing key
  40. 2 qwerty asdfgh
  41.  
  42. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement