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 895267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:31:54+00:00 2026-05-15T14:31:54+00:00

I have a multimap defined by typedef std::pair<int, int> au_pair; //vertices typedef std::pair<int, int>

  • 0

I have a multimap defined by

typedef std::pair<int, int> au_pair; //vertices
typedef std::pair<int, int> acq_pair; //ch qlty specified by C
typedef std::multimap<int, acq_pair> au_map;
typedef au_map::iterator It_au;

The no. of simulations depend on the size of the au_map. For eg: if the au_map.size() = 5 I will have C1, C2, C3, C4, C5. and therefore 2^5 = 32 cases.

For example: If the au_map.size()=4, I need to simulate my algorithm for 16 cases.

for(size_t i = 0; i != 16; ++i)
{
  for(It_au it = a_map.begin(); it != a_map.end();)
  {
    acq_pair it1 = it->second;
    //case 0:
    //C1 = 0, C2 = 0, C3 = 0, C4 = 0
    //@Matthieu M 's suggestion http://stackoverflow.com/questions/3110975/c-case-declaration-closed
    //bool const c1 = i & 1;
    //bool const c2 = i & 2;
    //bool const c3 = i & 4;
    //bool const c4 = i & 8;
    //Update it1.second with corresponding C values
    it->second.second = C1;
    it++;
    it->second.second = C2;
    it++;
    it->second.second = C3;
    it++;
    it->second.second = C4;
    it++;
  }
  //simulate algorithm
}

How can I automate this process, where the size of C changes according to the au_map.size()? Thus, I will have C1, C2, C3, C4 when au_map.size() = 4 and C1, C2, C3, C4, C5 when au_map.size() = 5.

Also, what’s preferred a vector with these values or add this to a pair inside multimap? Vector lookup time is lesser than multimap.

Also, if I keep inserting values to a multimap, will the new/updated values be passed to the algorithm?

  • 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-15T14:31:54+00:00Added an answer on May 15, 2026 at 2:31 pm

    Like others, I’m not certain I completely understand your question. It looks like all you need is a representation of the binary of each integer from 0 to 2bits-1 that you can conveniently reference (in the cases you mention, bits is either 4 or 5, but you want to generalize). If that’s the case, a simpler to manage and access structure will be a vector of bool vectors. That is, rather than using a std::multimap, for general values of bits, replace the std::multimap with a std::vector<std::vector<bool> >… something like:

    std::vector<std::vector<bool> > c_flags(1 << bits);
    
    for (size_t i = 0; i < c_flags().size(); ++i)
    {
        for (size_t j = 0; j < bits; ++j)
            c_flags[i].push_back( (i & (1 <&lt j)) > 0);
    }

    At this point, c_flags[i] contains a vector of bools representing the binary digits of i where true and false correspond to 1 and 0 respectively.

    You could also use a std::map<std::vector<bool> > instead of the std::vector<std::vector<bool> > which may reduce memory requirements (if you don’t need all of the possible binary representations) at the expense of being more expensive computationally. I don’t see why you need to use a std::multimap, but then I don’t have a lot of insight into the specifics of the problem you’re trying to address either.

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

Sidebar

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.