本文整理汇总了C++中std::multiset::find方法的典型用法代码示例。如果您正苦于以下问题:C++ multiset::find方法的具体用法?C++ multiset::find怎么用?C++ multiset::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::multiset
的用法示例。
在下文中一共展示了multiset::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find_and_remove
static bool find_and_remove(std::multiset<std::string>& files,
const std::string& filename)
{
std::multiset<std::string>::iterator ptr;
if ( (ptr = files.find(filename)) != files.end())
{
//erase(filename) erases *all* entries with that key
files.erase(ptr);
return true;
}
return false;
}
示例2: cancel
virtual bool cancel(int key)
{
#ifdef DEBUG
std::clog << "cancel" << std::endl;
#endif
bool ret = false;
pthread_mutex_lock(&cntLock);
if (boardingPass.count(key))
ret = true, boardingPass.erase(boardingPass.find(key));
preserveCnt--;
pthread_mutex_unlock(&cntLock);
return ret;
}
示例3: RemoveNeighbours
void ExpMapGenerator::RemoveNeighbours( ExpMapParticle * pParticle, std::multiset< ParticleQueueWrapper > & pq )
{
ExpMapParticle::ListEntry * pCur = GetNeighbourList( pParticle );
if ( pCur == NULL ) lgBreakToDebugger();
while ( pCur != NULL ) {
ExpMapParticle * pCurParticle = pCur->pParticle;
pCur = pCur->pNext;
if ( pCurParticle->State() != ExpMapParticle::Active )
continue;
// find entry in pq
#if 1
std::multiset<ParticleQueueWrapper>::iterator found(
pq.find( ParticleQueueWrapper( pCurParticle->SurfaceDistance() ) ) );
if ( found != pq.end() ) {
while ( (*found).Particle() != pCurParticle &&
(*found).QueueValue() == pCurParticle->SurfaceDistance() )
++found;
// [RMS: this should always happen...]
lgASSERT( (*found).Particle() == pCurParticle );
if ( (*found).Particle() == pCurParticle ) {
pq.erase( found );
}
} else {
lgASSERT( found != pq.end() );
}
#else
std::multiset<ParticleQueueWrapper>::iterator cur( pq.begin() );
bool bFound = false;
while ( !bFound && cur != pq.end() ) {
if ( (*cur).Particle() == pCurParticle ) {
pq.erase( cur );
bFound = true;
} else
++cur;
}
lgASSERT( bFound );
#endif
}
}
示例4: run
virtual Json::Value run(int key, int pid, int sid, const Json::Value &submission)
{
#ifdef DEBUG
std::clog << "run" << std::endl;
std::clog << " pid=" << pid << " sid=" << sid << " key=" << key << std::endl;
#endif
pthread_mutex_lock(&cntLock);
if (!boardingPass.count(key))
{
pthread_mutex_unlock(&cntLock);
Json::Value ret;
ret["error"] = "not preserved";
return ret;
}
boardingPass.erase(boardingPass.find(key));
runningCnt++, totCnt++;
const int _totCnt_ = totCnt;
pthread_mutex_unlock(&cntLock);
Json::Value ret;
std::ostringstream ss;
ss << runPath << "/" << _totCnt_;
std::string runDir = ss.str();
pthread_mutex_lock(&cmdLock);
#ifdef DEBUG
std::clog << "mkdir -p "+runDir << std::endl;
#endif
system(("mkdir -p "+runDir).c_str());
#ifdef DEBUG
std::clog << "rm -r "+runDir+"/*" << std::endl;
#endif
system(("rm -r "+runDir+"/*").c_str());
pthread_mutex_unlock(&cmdLock);
try
{
ss.str("");
ss << "cp " + dataPath + "/" << pid << "/* " << runDir;
pthread_mutex_lock(&syncLock);
if (syncing.count(pid)) pthread_mutex_unlock(&syncLock), throw std::string("data updated when copying files.");
#ifdef DEBUG
std::clog << ss.str() << std::endl;
#endif
pthread_mutex_lock(&cmdLock), system(ss.str().c_str()), pthread_mutex_unlock(&cmdLock);
pthread_mutex_unlock(&syncLock);
ss.str("");
ss << "cp " + sourcePath + "/" << sid/10000 << '/' << sid%10000 << "/* " << runDir;
#ifdef DEBUG
std::clog << ss.str() << std::endl;
#endif
pthread_mutex_lock(&cmdLock), system((ss.str()).c_str()), pthread_mutex_unlock(&cmdLock);
ss.str("");
ss << "./yauj_judge run";
for (Json::Value::const_iterator i=submission.begin(); i!=submission.end(); i++)
ss << " " << (*i)["language"].asString() << " " << (*i)["source"].asString();
ret=dumpCmd(ss.str(),runDir);
#ifndef NCLEAN
pthread_mutex_lock(&cmdLock), system(("rm -r "+runDir).c_str()), pthread_mutex_unlock(&cmdLock);
#endif
} catch (std::string &e)
{
#ifdef DEBUG
std::clog << " run: catched " << e << std::endl;
#endif
pthread_mutex_lock(&cntLock);
runningCnt--, preserveCnt--;
pthread_mutex_unlock(&cntLock);
ret["error"] = e;
return ret;
}
pthread_mutex_lock(&cntLock);
runningCnt--, preserveCnt--;
pthread_mutex_unlock(&cntLock);
return ret;
}