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

  • SEARCH
  • Home
  • 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 8195043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:00:17+00:00 2026-06-07T05:00:17+00:00

I have data in a particular format and I want to store them through

  • 0

I have data in a particular format and I want to store them through vectors/pairs/maps in c++.
eg:

Group A          Group B   Group C  ........
John             Matt      Shawn            
Jane             Liam      Tom              
.
.
.

There can be any number of groups and any number of names in them (all strings).
I expect as groups to be formed (which can be any in number) with any number of names in them. So I tried declaring them as a map or a pair.
The above format is what I want to store.
I tried doing it in this form:

Map<vector<int>, vector<string> > groups;
groups[i] = names.at(i);

Doesnt work.

The code of the method is:-

void form_groups(vector<string> teams){
          pair<vector<int>, vector<string> > groups;
          int num_teams_in_grp = 0;
          int group_num = 1;
          int i = 0;
          while( i < teams.size())
                  {
                          groups[group_num] = teams.at(i++);
                          num_teams_in_grp++; 
                  }       
                  group_num++;
         }
  • 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-06-07T05:00:19+00:00Added an answer on June 7, 2026 at 5:00 am

    You have been vague with your format so I’ll make the following assumption. You have some number of group names, and some number of groups, each group being defined as a set of members.

    I recommend storing them like this:

    #include <map>
    #include <set>
    
    ...
    
    // members of groups stored in sets, keyed by group name
    map<string, set<string> > groups; 
    
    ...
    
    // to access groups:
    set<string>& somegroup      = groups["Minions"];
    set<string>& someothergroup = groups["Judicators"];
    

    To add people to a group, using your specific data format, which I assume to be:

    Group1 Group2 Group3 ... GroupN
    Member1_Group1 Member2_Group1 Member3_Group1 ... MemberM_Group1
    ...
    Member1_GroupN Member2_GroupN Member3_GroupN ... MemberM_GroupN
    

    You would have to keep track of the indices of each group name so you could keep track of which group you were supposed to be adding members to, by line. For that purpose you might use something like the following C++ like pseudocode:

    vector<string> groups_by_index;            // stores group names by index numbers
    int current_line = 0;                      // stores the index of the group to add to
    
    for each item on line:                     // store group names by index
        groups_by_index.push_back(item);
    
    for each remaining line:                   // loop over each groups members
        for each item on line:
            groups[current_line].insert(item); // add member to group
        ++current_line;                        // increment group index
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have list of structure. I want to modify a particular data from the
I have a data frame where one particular column has a set of specific
I have an employee table, with the following data. For a particular manager, i
i have data-grid in my application and i want to customize my data-grid so
I'm trying to serialize a list of objects I have in a particular format.
I have a MDB listening to particular topic. I have configured XA data source
I want someone to help me, I have a case that seems very particular
I have a data set (currently in Access 2007 format) which has 2 tables,
I have 'data.xlsx' file with cells of numbers and letters. when I run this
I have data from travel diaries which has been read in from a csv

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.