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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:51:11+00:00 2026-06-10T18:51:11+00:00

This is probably really simple, but I can’t find a simple example for it.

  • 0

This is probably really simple, but I can’t find a simple example for it.
I understand that with a hash_multimap you can have several values mapped to a single key. But how exactly would I access those values. All the examples I stumbled across always just access the first value mapped to the the key. Heres an example of what I mean

key : value
1 : obj1a;
2 : obj2a, obj2b, obj2c

how would I access obj2b and obj2c, not just obj2a

  • 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-10T18:51:13+00:00Added an answer on June 10, 2026 at 6:51 pm

    The usual multimap iteration loop is like this:

    #include <unordered_multimap>
    
    typedef std::unordered_multimap<K, V> mmap_t;
    
    mmap_t m;
    
    for (mmap_t::const_iterator it1 = m.begin(), it2 = it1, end = m.end(); it1 != end; it1 = it2)
    {
        // outer loop over unique keys
    
        for ( ; it1->first == it2->first; ++it2)
        {
            // inner loop, all keys equal to it1->first
        }
    }
    

    To iterate over just one key value, use equal_range instead.

    std::pair<mmap_t::const_iterator, mmap_t::const_iterator> p = m.equal_range(key);
    
    for (mmap_t::const_iterator it = p.first; it != p.second; ++it)
    {
        // use "it->second"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a really simple question but I can't seem to find anything
This is probably a really simple question, but I just can't find any info
It is probably a really simple thing but can't find a solution. I have
This is probably something really simple but for some reason I just can't seem
Ok, this is probably really simple, but I just can't figure it out. I
This is probably a really simple one but I couldn't find the answer. I
It's probably something really simple, but I can't find it in the docs and
There is probably a really simple answer to this but I just can't see
This is probably a really simple question but I can't seem to get my
This is probably a really simple problem, but I can't figure out how to

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.