Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ hashmaps

#include <iostream>
#include <unordered_map>
using namespace std;
 
int main()
{
    unordered_map<string, int> sample;
    sample["first"] = 10;
    sample["second"] = 20;
    sample["third"] = 30;
 
    for (auto val : sample)
      cout << val.first << " " << val.second << endl;
 
}
Comment

hashmap c++

//me 
using namespace std;								//or use std::unordered_map
unordered_map<string,int> map =  {{"one", 1}, {"two", 2}};	//init
map["abc"] = 0;										//insert/change
cout << map["abc"];									//access value
map.erase("abc");									//delete
if (map.find("abc") == map.end()){}					//if 'abc' is not in map
for(auto& i: map){}									//iterate
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ client service ros 
Cpp :: C++ Integer Input/Output 
Cpp :: c++ program to find lcm of two numbers 
Cpp :: Nested if...else 
Cpp :: how to write a template c++ 
Cpp :: c ++ split_string 
Cpp :: number of nodes of bst cpp 
Cpp :: c++ array pointer 
Cpp :: c++ for each loop 
Cpp :: double array c++ 
Cpp :: how to input in cpp 
Cpp :: sfml keyboard events cpp 
Cpp :: find text in string c++ true false 
Cpp :: sum of first 100 natural numbers 
Cpp :: c++ open webpage 
Cpp :: c++ count vector elements 
Cpp :: dequeue c++ 
Cpp :: ue4 int to enum c++ 
Cpp :: opengl draw house using glut c++ 
Cpp :: c++98 check if character is integer 
Cpp :: namespace file linking c++ 
Cpp :: c++ define array with values 
Cpp :: delete c++ 
Cpp :: count c++ 
Cpp :: tower of hanoi 
Cpp :: c++ vector operations 
Cpp :: char at in c++ 
Cpp :: char input in c++ 
Cpp :: print numbers after decimal point c++ 
Cpp :: how to scan vector in c++ 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =