本文整理汇总了C++中multimap::rbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ multimap::rbegin方法的具体用法?C++ multimap::rbegin怎么用?C++ multimap::rbegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multimap
的用法示例。
在下文中一共展示了multimap::rbegin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateCharPhrases
int MarkovPhraseCreation::CreateCharPhrases(){
try
{
if (n == 1)
PrintChildCharPhrases(feed); // Special case n = 1. Unigram phrases has no state awareness.
else
{
// Iterate through the most common starts
__int64 progress = 0;
multimap<int, string>::reverse_iterator nextstartstate;
for (nextstartstate = startngrams.rbegin(); nextstartstate != startngrams.rend(); ++nextstartstate)
{
string startfeed = (feed.length() >= n) ? feed : nextstartstate->second;
int feedwords = count(startfeed.begin(), startfeed.end(), SPACE[0]);
startfeed.erase(remove(startfeed.begin(), startfeed.end(), BREAK[0]), startfeed.end());
startfeed.erase(remove(startfeed.begin(), startfeed.end(), SPACE[0]), startfeed.end());
PrintChildCharPhrases(startfeed, nextstartstate->second.substr(nextstartstate->second.length() - (n - 1)), 1+feedwords);
progress++;
time_t progresstime = time(NULL);
clog << "Done with phrases starting with \"" << startfeed << "\". About " << progress*100/startngrams.size() << "% done at " << ctime(&progresstime);
}
}
}
catch (const exception& e) {
cerr << e.what() << endl;
return 1;
}
return 0;
}
示例2: if
void
markFeats()
{
multimap<float, FeatureTree*, less<float> >::reverse_iterator
fRankIter = featRank.rbegin();
int i = 0 ;
bool justCut = false;
for( ; fRankIter != featRank.rend() ; fRankIter++)
{
float fRank = (*fRankIter).first;
FeatureTree* ft = (*fRankIter).second;
/* if(i++%500 == 2) cerr << i << " " << fRank << " " << *ft << endl;*/
//if(ft->featureInt == 4)
//cerr << i << " " << fRank << " " << *ft << endl;
if(totSelectedStates < totDesiredFeatures)
{
markFeat(ft, fRank);
}
else if(!justCut)
{
justCut = true;
cerr << "Just cut off at " << i << " " << fRank << endl;
}
}
}
示例3: CreateWordPhrases
int MarkovPhraseCreation::CreateWordPhrases()
{
try
{
if (n == 1)
PrintChildWordPhrases(feed); // Special case n = 1. Unigram phrases has no state awareness.
else
{
// Iterate through the most common starts
__int64 progress = 0;
multimap<int, string>::reverse_iterator nextstartstate;
for (nextstartstate = startngrams.rbegin(); nextstartstate != startngrams.rend(); ++nextstartstate)
{
string startphrase = feed;
startphrase.append(nextstartstate->second);
string startstate = nextstartstate->second;
// Prepare the start phrase by removing BREAKs and whitespaces
startphrase.erase(remove(startphrase.begin(), startphrase.end(), BREAK[0]), startphrase.end());
startphrase.erase(remove(startphrase.begin(), startphrase.end(), ' '), startphrase.end());
// And the start state by using the n-1 last words
int statebreakpos = nextstartstate->second.size() - 1;
for (int i = 0; i < n - 1; i++)
statebreakpos = nextstartstate->second.substr(0, statebreakpos).find_last_of(' ');
startstate = nextstartstate->second.substr(statebreakpos + 1);
// Start the recursive chain to print all phrases based on this start
PrintChildWordPhrases(startphrase, startstate, n-1);
progress++;
time_t progresstime = time(NULL);
clog << "Done with phrases starting with \"" << startphrase << "\". About " << progress * 100 / startngrams.size() << "% done at " << ctime(&progresstime);
}
}
}
catch (const exception& e) {
cerr << e.what() << endl;
return 1;
}
return 0;
}
示例4: print_times
void print_times(const multimap<size_t, string>& timing)
{
// set the column widths
int name_width = 0;
int time_width = 0;
for (const pair<size_t, string>& p : timing)
{
name_width = max(name_width, static_cast<int>(p.second.size()));
stringstream ss;
ss.imbue(locale(""));
ss << p.first;
time_width = max(time_width, static_cast<int>(ss.str().size()));
}
for (auto it = timing.rbegin(); it != timing.rend(); it++)
{
cout << setw(name_width + 2) << left << it->second << " " << setw(time_width + 2) << right
<< it->first << "us\n";
}
}
示例5: main
int main(){
memset(dist,-1,sizeof(dist));
cin>>n>>m>>k;
int i,j;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
for(i=0;i<n;i++)
scanf("%s",maps[i]);
for(i=0;i<n;i++)
for(j=0;j<m;j++)
if(maps[i][j]=='.'){
ox=j,oy=i;
i=n,j=m;
}
dist[oy][ox]=0;
que.push(P(ox,oy));
while(!que.empty()){
P tmp=que.front();
dists.insert(make_pair(dist[tmp.Y][tmp.X],tmp));
for(i=0;i<4;i++){
tmp.X=que.front().X+dx[i];
tmp.Y=que.front().Y+dy[i];
if(tmp.X<0 || m<=tmp.X || tmp.Y<0 || n<=tmp.Y
|| dist[tmp.Y][tmp.X]!=-1 || maps[tmp.Y][tmp.X]=='#')
continue;
dist[tmp.Y][tmp.X]=dist[que.front().Y][que.front().X]+1;
que.push(P(tmp.X,tmp.Y));
}
que.pop();
}/*
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%3d",dist[i][j]);
}cout<<endl;
}cout<<"[["<<k<<"]]"<<endl;*/
for(it=dists.rbegin(),i=0;it!=dists.rend()&&i<k;it++,i++){
// printf("(%d,%d)",it->Y.X,it->Y.Y);
maps[it->Y.Y][it->Y.X]='X';
}
for(i=0;i<n;i++)
printf("%s\n",maps[i]);
return 0;
}