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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:06:14+00:00 2026-05-15T15:06:14+00:00

typedef std::pair<int, bool> acq_pair; //edge, channel_quality typedef std::pair<int, acq_pair> ac_pair; typedef std::multimap<int, acq_pair> ac_map;

  • 0
typedef std::pair<int, bool> acq_pair; //edge, channel_quality
typedef std::pair<int, acq_pair> ac_pair;
typedef std::multimap<int, acq_pair> ac_map;
typedef ac_map::iterator It_acq;


int bits = acq_map.size();
std::cout << "bits = " << bits << std::endl;

std::vector<std::vector<bool> > c_flags (1 << bits);

for (i = 0; i < c_flags.size(); ++i)
{
    for (j = 0; j < bits; ++j)
    {
        c_flags[i].push_back( (i & (1 << j)) > 0);      
    }           
}

std::cout << "c_flags.size() = " << c_flags.size() << std::endl;

for(i = 0; i < c_flags.size(); ++i)
{
    for(j = 0; j < bits; ++j)
    {
        std::cout << c_flags[i][j] << std::endl;

        for(It_acq itc = acq_map.begin(); itc!= acq_map.end(); ++itc)
        {
            acq_pair it1 = itc->second;
            itc->second.second = c_flags[i][j];
            std::cout << itc->first << " : " << it1.first << " : " << it1.second << std::endl;
        }
    }   
    std::cout << "\n" << std::endl;
}

How can I access only one item from the multimap container at a time? I want to update only the jth value in the map, but when I iterate through the map all the bool values are changed. Is there a selective way to access the map container values?

  • 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-15T15:06:15+00:00Added an answer on May 15, 2026 at 3:06 pm

    The line itc->second.second = c_flags[i][j]; performed in a loop with itc from begin() to end() indeed performs assignment to every value of the map. If the goal was to modify only the j’th value in the map, there was no need for a loop over the entire map:

        for(size_t j = 0; j < bits; ++j)
        {
            std::cout << c_flags[i][j] << std::endl;
    
            It_acq itc = acq_map.begin(); // itc points at the beginning
            advance(itc, j); // itc points at the j'th element
            itc->second.second = c_flags[i][j]; // the assignment
    
            for(It_acq itc = acq_map.begin(); itc!= acq_map.end(); ++itc)
            {
                acq_pair it1 = itc->second;
    //            itc->second.second = c_flags[i][j];   // no assignment here
                std::cout << itc->first << " : " << it1.first << " : " << it1.second << std::endl;
            }
        }
    

    If this map is used for indexed access in this manner, it may be worthwhile to consider switching to vector, though.

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

Sidebar

Related Questions

I have a multimap defined by typedef std::pair<int, int> au_pair; //vertices typedef std::pair<int, int>
This is my code: typedef std::hash_multimap<Vertice<VerticeType, WeightType>*, Edge<VerticeType, WeightType>*> ght; std::pair<ght::iterator, ght::iterator> getEdgesFromVertice(Vertice<VerticeType, WeightType>*);
I have something like this: #include <iostream> namespace N { typedef std::pair<int, double> MyPair;
Suppose some data structure: typedef struct { std::string s; int i; } data; If
Here is my map: typedef std::map<int/*security id*/, PositionMonth> PortfolioMonth; where PositionMonth is a structure,
Since std::pair<std::string, unsigned int> is not defined for __gnu_cxx hash map, how do I
I've got a structure as follows: typedef struct { std::wstring DevAgentVersion; std::wstring SerialNumber; }
I have the below code in stdafx.h. using namespace std; typedef struct { DWORD
Given an integer typedef: typedef unsigned int TYPE; or typedef unsigned long TYPE; I
I have a function pointer defined by: typedef void (*EventFunction)(int nEvent); Is there a

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.