fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4. #include <string>
  5.  
  6. int main() {
  7. typedef std::vector< std::string > strings_t;
  8. typedef std::multimap<int, strings_t > map_t;
  9. map_t m;
  10.  
  11. {
  12. strings_t v;
  13. v.push_back( "one" ); v.push_back( "two" ); v.push_back( "three" );
  14. m.insert( std::make_pair( 1, v ) );
  15. }
  16. {
  17. strings_t v;
  18. v.push_back( "ten" ); v.push_back( "twenty" ); v.push_back( "thirty" );
  19. m.insert( std::make_pair( 10, v ) );
  20. }
  21. {
  22. strings_t v;
  23. v.push_back( "foutry" ); v.push_back( "two" );
  24. m.insert( std::make_pair( 42, v ) );
  25. }
  26.  
  27. for ( map_t::const_iterator i = m.begin(), e = m.end(); i != e; ++i ) {
  28. std::cout << i->first << " : " << std::endl;
  29. for ( strings_t::const_iterator i_v = i->second.begin(), e_v = i->second.end(); i_v != e_v; ++i_v ) {
  30. std::cout << (*i_v) << std::endl;
  31. }
  32. }
  33. }
Success #stdin #stdout 0s 2868KB
stdin
Standard input is empty
stdout
1 : 
one
two
three
10 : 
ten
twenty
thirty
42 : 
foutry
two