c++ - How do I print out elements in a multimap ONLY n times -


my multimap has int key , string value. key number of times word has occurred , value word itself. figured if loop through multimap iterator @ rbegin , rend, can loop through ten times rather until reaches end find top ten words. idea how this?

sure! here's 1 option:

unsigned numtimes = 0; (auto itr = mymultimap.rbegin();      itr != mymultimap.rend() && numtimes < kmaxtimes;      ++itr, ++numtimes) {      /* itr */  } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -