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 | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 151 |
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.