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 :: how to get the time in c++ as string 
Cpp :: c++ progress bar 
Cpp :: chudnovsky algorithm c++ 
Cpp :: function in struct c++ 
Cpp :: how to write hello world in c++ 
Cpp :: max in c++ 
Cpp :: implementing split function in c++ 
Cpp :: Find minimum maximum element CPP 
Cpp :: odd numbers 1 to 100 
Cpp :: c++ contains 
Cpp :: if statement c++ 
Cpp :: c++ string conversion operator 
Cpp :: Reverse words in a given string solution in c++ 
Cpp :: c++ program to convert kelvin to fahrenheit 
Cpp :: c function as paramter 
Cpp :: c++ doubly linked list 
Cpp :: c ++ splitlines 
Cpp :: c++ auto 
Cpp :: map in c 
Cpp :: C++ Integer Input/Output 
Cpp :: Traversing a C++ Array 
Cpp :: variables in c++ 
Cpp :: how to input in cpp 
Cpp :: uparam(ref) 
Cpp :: how to remove the scroll bar in pyqt6 
Cpp :: how to reset linerenderer unity 
Cpp :: find vector size in c++ 
Cpp :: find maximum sum in array of contiguous subarrays 
Cpp :: move assignment operator c++ 
Cpp :: c++ define array with values 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =