unordered_map
snippet in c

unordered_map c++

user8068

// C++ program to demonstrate functionality of unordered_map 
#include <iostream> 
#include <unordered_map> 
using namespace std; 
  
int main() 
{ 
    // Declaring umap to be of <string, int> type 
    // key will be of string type and mapped value will 
    // be of double type 
    unordered_map<string, int> umap; 
  
    // inserting values by using [] operator 
    umap["GeeksforGeeks"] = 10; 
    umap["Practice"] = 20; 
    umap["Contribute"] = 30; 
  
    // Traversing an unordered map 
    for (auto x : umap) 
      cout << x.first << " " << x.second << endl; 
  
} 

unordered_map

user2074

unordered_map is an associated container that stores elements formed by combination of key value and a mapped value. 
The key value is used to uniquely identify the element and mapped value is the content associated with the key. 
Both key and value can be of any type predefined or user-defined.