Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6701949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:59:42+00:00 2026-05-26T06:59:42+00:00

typedef map<int, string> iMap; typedef map<double, innerMap> OutMap; OutMap mx; map<double, iMap >::iterator it_out;

  • 0
typedef map<int, string> iMap;
typedef map<double, innerMap> OutMap;

OutMap mx;

map<double, iMap >::iterator it_out;
map<int, string>::iterator it_i;

for ( it_out=mx.begin() ; it_out != mx.end(); it_out++ ) {
   cout << "\n\nNew element\n" << (*it_out).first << endl;
   for( it_i=(*it_out).second.begin(); it_i != (*it_out).second.end(); it_out++)
     cout << (*it_i).first << " => " << (*it_i).second << endl;
}

I’m pretty sure the above code is fine…
Is there any performance issue…?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:59:42+00:00Added an answer on May 26, 2026 at 6:59 am

    It cannot be improved further, except that

    • You can use pre-increment instead of post-increment, i.e ++it_out instead of it_out++.
    • You can use '\n' instead of endl in the cout. Using '\n' would improve the performance of output operation by reasonable margin, because endl first puts '\n' in the output buffer, and then flushes it to the destination (stdout in this case) which makes it slow operation.

    Note that you should increment it_i (as opposed to it_out) in the inner for loop. I suppose that is a typo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have two maps: typedef int Id; std::map<Id, std::string> idToStringMap; std::map<Id, double>
Consider this program: #include <map> #include <vector> typedef std::vector<int> IntVector; typedef std::map<IntVector,double> Map; void
for(ItemTemplateListIterator iter = item_template_list.begin(); iter != item_template_list.end(); ++iter) { int id = iter->first; string
I have the following two boost::fusion maps. namespace bf = boost::fusion; typedef bf::map<bf::pair<char,float>,bf::pair<int,double>> FusionMap;
In C++ often do something like this: typedef map<int, vector<int> > MyIndexType; Where I
void main() { typedef boost::ptr_map<int, char> MyMap; //typedef std::map<int, char *> MyMap; // in
In code below: map<string,vector<int>> create(ifstream& in, const vector<string>& vec) { /*holds string and line
Suppose some data structure: typedef struct { std::string s; int i; } data; If
I have a vector of maps: typedef map<string, string> aMap; typedef vector<aMap> rVec; rVec
#include stdafx.h #include <string> #include <map> using namespace std; class NiftyEmailProgram { private: typedef

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.