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 | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 166 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
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.