Skip to content

Instantly share code, notes, and snippets.

@royerk
Created September 11, 2019 02:43
Show Gist options
  • Save royerk/3371541565a2026ac28e3a037a7dd717 to your computer and use it in GitHub Desktop.
Save royerk/3371541565a2026ac28e3a037a7dd717 to your computer and use it in GitHub Desktop.
C++ map<int, map<int, int>>
// 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