Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <boost/unordered_map.hpp>
- int main()
- {
- boost::unordered_map<int, std::vector<std::string> > map;
- std::cout << "Usage without any initialization:\n";
- std::cout << map[0].size() << "\n\n";
- map[1].push_back("qwerty");
- std::cout << "Insertion with non-existing key\n";
- std::cout << map[1].size() << " " << map[1][0] << "\n\n";
- map[1].push_back("asdfgh");
- std::cout << "Insertion with existing key\n";
- std::cout << map[1].size() << " " << map[1][0] << " " << map[1][1] << "\n\n";
- map[0] = map[1];
- std::cout << "Overwriting of existing key\n";
- std::cout << map[0].size() << " " << map[0][0] << " " << map[0][1] << "\n\n";
- return 0;
- }
- /*
- Output:
- Usage without any initialization:
- 0
- Insertion with non-existing key
- 1 qwerty
- Insertion with existing key
- 2 qwerty asdfgh
- Overwriting of existing key
- 2 qwerty asdfgh
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement