本文整理汇总了C++中multimap类的典型用法代码示例。如果您正苦于以下问题:C++ multimap类的具体用法?C++ multimap怎么用?C++ multimap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了multimap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
int n, id, power, lower_power = 0, higher_power;
s.insert(make_pair(1000000000, 1));
scanf("%d", &n);
while (n--) {
scanf("%d %d", &id, &power);
multimap<int, int>::iterator p;
p = s.insert(make_pair(power, id));
if (p == s.begin()) {
++p;
printf("%d %d\n", id, p->second);
}
else if (p == s.end()) {
printf("%d %d\n", id, p->second);
}
else {
--p;
lower_power = p->first;
++p; ++p;
higher_power = p->first;
if ((higher_power - power) < (power - lower_power)) {
printf("%d %d\n", id, p->second);
}
else {
--p; --p;
printf("%d %d\n", id, p->second);
}
}
}
return 0;
}
示例2: set
void set(int key, int value)
{
multimap<int, V2C>::iterator it = key2Value2Count.find(key);
if(it != key2Value2Count.end())
{
V2C& tmp = it->second;
tmp.value = value;
get(key);
}
else
{
if(count >= max)
{
list<int>::iterator cit=count2Key.begin();
// cout << "cache eviction: " << *cit << endl;
key2Value2Count.erase(*cit);
count2Key.erase(cit);
count--;
}
list<int>::iterator iit = count2Key.insert(count2Key.end(),key);
V2C tmp;
tmp.value = value;
tmp.it = iit;
// cout << "xxxx" <<*iit<<endl;
key2Value2Count.insert(pair<int, V2C>(key, tmp));
count++;
}
}
示例3: delete_author
void delete_author(multimap<string, string> &books, const string &name){
auto p = books.equal_range(name);
if (p.first == p.second)
cout << "No author named " << name << endl;
else
books.erase(p.first, p.second);
}
示例4: SV_SectorList_f
void SV_SectorList_f( void )
{
areaParms_t ap;
// ap.mins = mins;
// ap.maxs = maxs;
// ap.list = list;
// ap.count = 0;
// ap.maxcount = maxcount;
entStats.clear();
SV_AreaEntitiesTree(sv_worldSectors,&ap,0);
char mess[1000];
multimap<int,pair<int,list<CBBox> > >::iterator j;
for(j=entStats.begin();j!=entStats.end();j++)
{
sprintf(mess,"**************************************************\n");
Sleep(5);
OutputDebugString(mess);
sprintf(mess,"level=%i, count=%i\n",(*j).first,(*j).second.first);
Sleep(5);
OutputDebugString(mess);
list<CBBox>::iterator k;
for(k=(*j).second.second.begin();k!=(*j).second.second.end();k++)
{
sprintf(mess,"mins=%f %f %f, maxs=%f %f %f\n",
(*k).mMins[0],(*k).mMins[1],(*k).mMins[2],(*k).mMaxs[0],(*k).mMaxs[1],(*k).mMaxs[2]);
OutputDebugString(mess);
}
}
}
示例5: locker
/* Look for mime handler in pool */
static RecollFilter *getMimeHandlerFromCache(const string& key)
{
PTMutexLocker locker(o_handlers_mutex);
string xdigest;
MD5HexPrint(key, xdigest);
LOGDEB(("getMimeHandlerFromCache: %s cache size %u\n",
xdigest.c_str(), o_handlers.size()));
multimap<string, RecollFilter *>::iterator it = o_handlers.find(key);
if (it != o_handlers.end()) {
RecollFilter *h = it->second;
hlruit_tp it1 = find(o_hlru.begin(), o_hlru.end(), it);
if (it1 != o_hlru.end()) {
o_hlru.erase(it1);
} else {
LOGERR(("getMimeHandlerFromCache: lru position not found\n"));
}
o_handlers.erase(it);
LOGDEB(("getMimeHandlerFromCache: %s found size %u\n",
xdigest.c_str(), o_handlers.size()));
return h;
}
LOGDEB(("getMimeHandlerFromCache: %s not found\n", xdigest.c_str()));
return 0;
}
示例6: timeout_alarm
void timeout_alarm(int) {
cout << "!timeout alarm" << endl;
struct timeval tv;
struct timezone tz;
multimap<long, client_timeout>::iterator i;
long ts;
for (i = timestamp_map.begin(); i != timestamp_map.end();) {
gettimeofday(&tv, &tz); // pobranie aktualnego czasu
ts = tv.tv_sec * 1000 + tv.tv_usec / 1000; // zamiana na ms
if (i->first > ts)
break;
map<int, resource_clients>::iterator j = resource_map.find(
i->second.resource_id);
list<client>::iterator k = find_by_pid(j->second.waiting_clients,
i->second.pid);
j->second.waiting_clients.erase(k); // usuniecie klienta z kolejki oczekujacych
send_response(i->second.pid, TIMEDOUT);
timestamp_map.erase(i++); // usuniecie klienta z kolejki timeout
try_grant(j); // proba przydzielenia zasobu
}
if (!timestamp_map.empty()) {
useconds_t alrm = (i->first - ts) * 1000;
ualarm(alrm, 0);
}
cout << "!end of timeout alarm" << endl;
}
示例7: markFeats
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;
}
}
}
示例8: plotCorrespondences
void POICorrespondence::plotCorrespondences(const Mat& img1, vector<Point>& corners1, const Mat& img2,
multimap<Point, Point, PointCompare> &correspondences, Mat& dst)
{
dst.create(max(img1.rows, img2.rows), img1.cols + img2.cols, img1.type());
//ROI of bigger image pointing to first half
Mat dstImg1 = dst(Rect(0, 0, img1.cols, img1.rows));
//ROI of bigger image pointing to second half
Mat dstImg2 = dst(Rect(img1.cols, 0, img2.cols, img2.rows));
img1.copyTo(dstImg1);
img2.copyTo(dstImg2);
//Draw green lines
Scalar colorL(0, 255, 0);
int xP2;
map<Point, Point>::iterator it;
for (it = correspondences.begin(); it != correspondences.end(); ++it)
{
//Displace point in image2 since its located in the second half of the big image
xP2 = it->second.x + img1.cols;
line(dst, it->first, Point(xP2, it->second.y), colorL, 1, CV_AA);
}
}
示例9: if
// Maps highest frequency of codons to each amino acid
vector<float> CodonFrequency::createMaxMap(multimap<char, pair<int, float> > AAtoCodonMap){
// cout << "------maxFreq------" << endl;
vector<float> maxMap;
float maxFreq;
// Loops through all amino acids
// If char rep of AA exists
// Calculate highest frequency to maxMap
for (char AA = 'A'; AA <= 'Z'; AA++) {
int addressAA = AA - 65;
if (AA == 'B' || AA == 'J' || AA == 'O' || AA == 'U' || AA == 'X') {
maxMap.push_back(-1);
// continue;
}
else if (AAtoCodonMap.count(AA) > 1) {
maxFreq = findMax(AAtoCodonMap, AA);
maxMap.push_back(maxFreq);
// continue;
} else if (AAtoCodonMap.count(AA) == 1) {
maxMap.push_back(AAtoCodonMap.find(AA)->second.second);
}
// to print values: comment out the continues in if statements
// cout << addressAA << " " << AA << " " << maxMap[addressAA] << endl;
}
return maxMap;
}
示例10: writeMetadataFile
void writeMetadataFile( const string coll, boost::filesystem::path outputFile,
map<string, BSONObj> options, multimap<string, BSONObj> indexes ) {
log() << "\tMetadata for " << coll << " to " << outputFile.string() << endl;
ofstream file (outputFile.string().c_str());
uassert(15933, "Couldn't open file: " + outputFile.string(), file.is_open());
bool hasOptions = options.count(coll) > 0;
bool hasIndexes = indexes.count(coll) > 0;
if (hasOptions) {
file << "{options : " << options.find(coll)->second.jsonString();
if (hasIndexes) {
file << ", ";
}
} else {
file << "{";
}
if (hasIndexes) {
file << "indexes:[";
for (multimap<string, BSONObj>::iterator it=indexes.equal_range(coll).first; it!=indexes.equal_range(coll).second; ++it) {
if (it != indexes.equal_range(coll).first) {
file << ", ";
}
file << (*it).second.jsonString();
}
file << "]";
}
file << "}";
}
示例11: PrintChildCharPhrases
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;
}
示例12: logoutReq
//handle login requests
int logoutReq(struct request_logout *rl)
{
string username = getUserOfCurrAddr();
multimap<string, struct sockaddr_in>::iterator sockIt = userToAddrStrct.find(username);
userToAddrStrct.erase(sockIt);
map<string,vector<string> >::iterator git;
git = usrTlkChan.find(username);
if(git != usrTlkChan.end()) {
usrTlkChan.erase(username);
}
//erase user on channels in chanTlkUser
//for(int ick=0; ick<channels.size(); ick++) {
map<string,vector<pair<string,struct sockaddr_in> > >::iterator sat;
for(sat=chanTlkUser.begin(); sat != chanTlkUser.end(); sat++) {
map<string,vector<pair<string,struct sockaddr_in> > >::iterator itck = chanTlkUser.find(sat->first);
vector<pair<string,struct sockaddr_in> > usersC = itck->second;
for(int j=0; j<usersC.size(); j++) {
if(usersC[j].first == username) {
usersC.erase(usersC.begin()+j);
}
}
chanTlkUser.erase(itck);
chanTlkUser.insert(pair<string,vector<pair<string,struct sockaddr_in> > >(sat->first,usersC));
}
return 0;
}
示例13: loginReq
//handle login requests
int loginReq(struct request_login *rl)
{
string username = rl->req_username;
struct sockaddr_in strctAddr = getAddrStruct();
userToAddrStrct.insert(userToAddrStrct.end(), pair<string, struct sockaddr_in>(username, strctAddr));
return 0;
}
示例14: init
void init() {
double INF = 262144;
S.clear();
S.insert(make_pair(Seg(Pt(-INF, -INF), Pt(INF, -INF), -1, -1), (Triangle*)NULL));
S.insert(make_pair(Seg(Pt(-INF, INF), Pt(INF, INF), -1, -1), (Triangle*)NULL));
status = 0;
}
示例15: fun
int fun(){
int i;
for(i=1;i<root;i++){
if(freq[i] ==0 ){
leaf.push(i);
}
}
int f, p;
i = 0;
while(! leaf.empty() ){
f = leaf.top(); leaf.pop();
p = node[i];
edge.insert( make_pair(p, f) );
if(--freq[p] == 0 && p < root-1){
leaf.push(p);
}
i++;
}
edge.erase(0);
printf("(");
traceback(root-1);
printf(")\n");
edge.clear();
}