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?
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 | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 163 |
4 | TheScrasse | 159 |
5 | nor | 157 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 152 |
8 | Petr | 146 |
8 | orz | 146 |
10 | pajenegod | 145 |
Название |
---|
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.