Can anybody tell me about C++ multimaps. As far as I know you can assign many values to a key but... how do I access to any of theese values?
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Can anybody tell me about C++ multimaps. As far as I know you can assign many values to a key but... how do I access to any of theese values?
Name |
---|
How can I know how many values are assigned to every key and how can I make reference to each of the values a key has?
l = m.lower_bound(key);
u = m.upper_bound(key);
c = std::distance(l, u);
Thanks two of you for help
Unfortunately they didn't tell you how to use multimap. Here's an example.
That's true, their comments were helpful but what i wanted was an example of using multimap. Could you make a comment with the example, my internet provider does not allow me to go that link
I see, very ilustrative example. I've never used auto I gess it make the variable get the type that is asigned to it, am I right?
Yes, the compiler will deduce the type for you. auto is quite a bit shorter to write than pair<multimap<int,string>::iterator,multimap<int,string>::iterator>.
I recommend reading these two posts (C++11 for programming contests... and C++ Tricks) for some additional info on using C++11 in programming contests.