Difference between revisions of "CPP/STL/MultiMap"
From ProgrammingExamples
< CPP
Daviddoria (Talk | contribs) (Created page with '==MultiMap.cpp== <source lang="cpp"> #include <iostream> #include <map> int main(int argc, char *argv[]) { std::multimap <int, double> MyMap; //create a mapping from "t…') |
m |
||
Line 10: | Line 10: | ||
//create a mapping from "testone" to 111 | //create a mapping from "testone" to 111 | ||
− | MyMap.insert(std:: | + | MyMap.insert(std::make_pair(1, 1.2)); |
//create an iterator | //create an iterator |
Revision as of 00:08, 15 June 2011
MultiMap.cpp
#include <iostream> #include <map> int main(int argc, char *argv[]) { std::multimap <int, double> MyMap; //create a mapping from "testone" to 111 MyMap.insert(std::make_pair(1, 1.2)); //create an iterator std::map<int, double>::iterator iter; iter = MyMap.find(1); if(iter == MyMap.end()) { std::cout << "Not found." << std::endl; } else { std::cout << "Found: " << iter->second << std::endl; } return 0; }