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?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3839 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | Geothermal | 3569 |
7 | cnnfls_csy | 3569 |
9 | ecnerwala | 3494 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | Um_nik | 164 |
2 | maomao90 | 160 |
3 | -is-this-fft- | 159 |
4 | atcoder_official | 158 |
4 | cry | 158 |
4 | awoo | 158 |
7 | adamant | 155 |
8 | nor | 154 |
9 | TheScrasse | 153 |
10 | Dominater069 | 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?
Название |
---|
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.