Created
September 11, 2019 02:43
-
-
Save royerk/3371541565a2026ac28e3a037a7dd717 to your computer and use it in GitHub Desktop.
C++ map<int, map<int, int>>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++17 for structure binding | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
#include <map> | |
using namespace std; | |
int main() | |
{ | |
map<int, map<int,int>> mapmap = {}; | |
mapmap[1][2] = 3; | |
mapmap[1][3] = 30; | |
mapmap[0][0] = 0; | |
for(auto& [k, v]: mapmap[1]) | |
cout << "mapmap[1]:" << k << " " << v << endl; | |
cout << endl; | |
for(auto& [k, v]: mapmap[500]) | |
cout << "mapmap[500]:" << k << " " << v << endl; | |
cout << "size of 500: " << mapmap[500].size() << endl; | |
cout << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment