c++ - Mapping int and string values to Map<Integer, List<String>> -


in program sort of result:

2:one 3:ff 3:rr 6:fg 

i want send data using send() method in socket can word occurrence , word @ receiving socket.

i think map<integer, list<string>> better option.

my code snippet:

   (std::map < int, std::vector < std::string > >::iterator hit = three_highest.begin(); hit != three_highest.end(); ++hit) {         //std::cout << hit->first << ":";          (std::vector < std::string >::iterator vit = (*hit).second.begin(); vit != (*hit).second.end(); vit++) {             std::cout << hit->first << ":";             std::cout << *vit << "\n"; } } 

hit->first gives occurrence[int val], *vit gives string.

how can store : map<integer, list<string>> each iteration?

you construct lists , insert them map.

std::map<int, std::list<std::string> > map_to_string_list;  (auto list_it = three_highest.begin(); list_it != three_highest.end(); ++list_it) {     map_to_string_list[list_it->first] = std::list<std::string>(list_it->second.begin(),                                                                 list_it->second.end()); } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -