#include <iostream>
#include <unordered_map>
int main()
{
std::unordered_map<std::string, int> numbers{
{"zero" , 0},
{"one" , 1},
{"two" , 2},
{"three", 3}};
std::cout << numbers["one" ] << " " <<
numbers["two" ] << " " <<
numbers["three"] << std::endl;
return 0;
}
// Output: 1 2 3
Reference: https://isocpp.org/wiki/faq/cpp11-library-stl#std-unordered
Friday, September 1, 2017
C++11: Containers: unordered_map, unordered_set, unordered_multimap, unordered_multiset
Hash containers were added. Here is an example.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment