• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ multimap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中multimap的典型用法代码示例。如果您正苦于以下问题:C++ multimap类的具体用法?C++ multimap怎么用?C++ multimap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了multimap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:BuFann,项目名称:Another-set-of-homework-Cpp,代码行数:32,代码来源:Question+5.cpp


示例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++;
            }
        }
开发者ID:hotbig,项目名称:letmetry,代码行数:34,代码来源:LRU_cache_v5.cpp


示例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);
}
开发者ID:buaakq,项目名称:cpp_primer,代码行数:7,代码来源:task_11_31.cpp


示例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);
		}
	}

}
开发者ID:Camron,项目名称:OpenJK,代码行数:32,代码来源:sv_world.cpp


示例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;
}
开发者ID:norandom,项目名称:recoll,代码行数:26,代码来源:mimehandler.cpp


示例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;
}
开发者ID:cinek90,项目名称:DLM-via-FIFO,代码行数:27,代码来源:main.cpp


示例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;
	}
    }
}
开发者ID:KerstenDoering,项目名称:CPI-Pipeline,代码行数:26,代码来源:selFeats.C


示例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);
	}
}
开发者ID:ZePoLiTaT,项目名称:ComputerVisionCourse-UTP,代码行数:26,代码来源:POICorrespondence.cpp


示例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;
}
开发者ID:FindKim,项目名称:MinMax,代码行数:34,代码来源:CodonFrequency.cpp


示例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 << "}";
    }
开发者ID:tanakh,项目名称:mongo,代码行数:32,代码来源:dump.cpp


示例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;
}
开发者ID:Tourountzis,项目名称:Phraser,代码行数:33,代码来源:Phraser.cpp


示例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;
}
开发者ID:jziesing,项目名称:UDP_Server,代码行数:27,代码来源:w:out_channels.cpp


示例13: getInputs

void DeviceParser::getInputs(string tagname, multimap<string, std::string> &m)
{
  setNode(tagname);
  DOMNode * temp = node->FirstChildElement();

  while (temp)
  {
    if (temp->ValueStr().compare("button") == 0	||
	temp->ValueStr().compare("slider") == 0 ||
	temp->ValueStr().compare("sensor") == 0)
      m.insert(pair<string, std::string>(getAttribute(temp,"name"), getAttribute(temp,"id")));

    else if (temp->ValueStr().compare("dpad") == 0 ||
	     temp->ValueStr().compare("stick") == 0 )
    {
      m.insert(pair<string, std::string>(getAttribute(temp,"name"), getAttribute(temp,"idtd")));
      m.insert(pair<string, std::string>(getAttribute(temp,"name"), getAttribute(temp,"idlr")));
    }
    else if (temp->ValueStr().compare("tracker2room") == 0 ||
	     temp->ValueStr().compare("workspace") == 0)
    {
      m.insert(pair<string, std::string>("type", getAttribute(temp,"type")));
    }
    
    temp = temp->NextSiblingElement();
  }

  delete temp;
}
开发者ID:bilgili,项目名称:FlowVR,代码行数:29,代码来源:deviceparser.cpp


示例14: dfs

bool dfs(string &s){
    e.insert(s);
    v.push_back(s);
    for(multimap<string,string>::iterator it=h.lower_bound(s); 
            it!=h.end()&&it->first==s; ++it){
        if(e.find(it->second) != e.end()){
            continue;
        }
        map<string, int>::iterator mi = r.find(it->second);
        if(mi != r.end()){
            /*
            v.push_back(it->second);
            reverse(v.begin(), v.end());
            for(vector<string>::iterator vi=v.begin(); vi!=v.end(); vi++){
                cout<<*vi<<" ";
            }
            cout<<endl;
            */
            if(--mi->second<=0){
                r.erase(mi);
            }
            return true;
        } else if(dfs(it->second)){
            return true;
        }
    }
    v.pop_back();
    return false;
}
开发者ID:ZhouWeikuan,项目名称:zoj,代码行数:29,代码来源:1157.cpp


示例15: get

        int get(int key){ 
            multimap<int, V2C>::iterator it = key2Value2Count.find(key);
            if(it != key2Value2Count.end())
            {
                V2C& tmp = it->second;
#if 0
                pair <multimap<int,int>::iterator, multimap<int,int>::iterator> ret;
                ret = count2Key.equal_range(tmp.count);
                for(multimap<int,int>::iterator it=ret.first; it!=ret.second;++it)
                {
                    if(it->second == key)
                    {
                        count2Key.erase(it);
                        tmp.count++;
                        count2Key.insert(pair<int, int>(tmp.count, key));
                        break;
                    }
                }
#endif
                count2Key.erase(tmp.it);
                list<int>::iterator iit = count2Key.insert(count2Key.end(),key);
                tmp.it=iit;
#if 0
                cout << "cache hit" << key << endl;
#endif
                return tmp.value;
            }
            else
            {
        //        cout << "cache miss" << key << endl;
                return -1;
            }
        }
开发者ID:hotbig,项目名称:letmetry,代码行数:33,代码来源:LRU_cache_v5.cpp


示例16:

    void operator& (multimap<double,double> x, ostream& stream) {
	x.size() & stream;
	for (multimap<double,double>::const_iterator pos = x.begin (); pos != x.end() ; ++pos) {
	    pos->first & stream;
	    pos->second & stream;
	}
    }
开发者ID:dhardy,项目名称:openmalaria,代码行数:7,代码来源:checkpoint.cpp


示例17: checkBadDest

int Slave::checkBadDest(multimap<int64_t, Address>& sndspd, vector<Address>& bad)
{
   bad.clear();

   if (sndspd.empty())
      return 0;

   int m = sndspd.size() / 2;
   multimap<int64_t, Address>::iterator p = sndspd.begin();
   for (int i = 0; i < m; ++ i)
      ++ p;

   int64_t median = p->first;

   int locpos = 0;
   for (multimap<int64_t, Address>::iterator i = sndspd.begin(); i != sndspd.end(); ++ i)
   {
      if (i->first > (median / 2))
         return bad.size();

      bad.push_back(i->second);
      locpos ++;
   }

   return bad.size();
}
开发者ID:norouzi4d,项目名称:sector,代码行数:26,代码来源:serv_spe.cpp


示例18: writeMetadataFile

    void writeMetadataFile( const string coll, boost::filesystem::path outputFile, 
                            map<string, BSONObj> options, multimap<string, BSONObj> indexes ) {
        toolInfoLog() << "\tMetadata for " << coll << " to " << outputFile.string() << std::endl;

        bool hasOptions = options.count(coll) > 0;
        bool hasIndexes = indexes.count(coll) > 0;

        BSONObjBuilder metadata;

        if (hasOptions) {
            metadata << "options" << options.find(coll)->second;
        }

        if (hasIndexes) {
            BSONArrayBuilder indexesOutput (metadata.subarrayStart("indexes"));

            // I'd kill for C++11 auto here...
            const pair<multimap<string, BSONObj>::iterator, multimap<string, BSONObj>::iterator>
                range = indexes.equal_range(coll);

            for (multimap<string, BSONObj>::iterator it=range.first; it!=range.second; ++it) {
                 indexesOutput << it->second;
            }

            indexesOutput.done();
        }

        ofstream file (outputFile.string().c_str());
        uassert(15933, "Couldn't open file: " + outputFile.string(), file.is_open());
        file << metadata.done().jsonString();
    }
开发者ID:ANTco,项目名称:mongo,代码行数:31,代码来源:dump.cpp


示例19: double

map<string, double> indri::query::ConceptSelectorFuns::normConceptScoreFreq(indri::api::QueryEnvironment & env,
                                                            map<string, int> conceptsFrq,
                                                            multimap<double, pair<string, string> > scoredConcepts_norm )
{

    // extract concept freq for the concepts exist in scoredConcepts_norm and store it in a container
    map<string, double> conceptsFrqExtr_norm;
    double max_cf = 0;
    double min_cf = std::numeric_limits<double>::infinity();;
    for (auto itSc = scoredConcepts_norm.begin(); itSc != scoredConcepts_norm.end(); itSc++)
    {
        conceptsFrqExtr_norm[(itSc->second).second] = conceptsFrq[(itSc->second).second] / double(env.documentCount());
        max_cf = max(max_cf, conceptsFrqExtr_norm[(itSc->second).second]);
        min_cf = min(min_cf, conceptsFrqExtr_norm[(itSc->second).second]);

        cout << "indri::query::ConceptSelectorFuns::normConceptScoreFreq: conceptsFrqExtr_norm: min_cf, max_cf: " << min_cf << ", " << max_cf << endl;
        cout << "indri::query::ConceptSelectorFuns::normConceptScoreFreq: scoredConcepts_norm: " << (itSc->second).second << " " << itSc->first << endl;
        cout << "indri::query::ConceptSelectorFuns::normConceptScoreFreq: conceptsFrq: " << (itSc->second).second << " " << conceptsFrq[(itSc->second).second] << endl;
    }

    // normalize the extracted concepts' scores
    map<string, double> conceptsFrqExtr_norm1;
    for (auto itCf = conceptsFrqExtr_norm.begin(); itCf != conceptsFrqExtr_norm.end(); itCf++)
    {
        conceptsFrqExtr_norm1[itCf->first] = (itCf->second-min_cf)/(max_cf-min_cf);
        cout << "indri::query::ConceptSelectorFuns::normConceptScoreFreq: conceptsFrqExtr_norm1: " << itCf->first << " " << conceptsFrqExtr_norm1[itCf->first] << endl;
    }
    return conceptsFrqExtr_norm1;
}
开发者ID:teanalab,项目名称:MRF-L,代码行数:29,代码来源:ConceptSelectorFuns.cpp


示例20: 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;
}
开发者ID:jziesing,项目名称:UDP_Server,代码行数:8,代码来源:server22.cpp



注:本文中的multimap类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ multiname类代码示例发布时间:2022-05-31
下一篇:
C++ mtl类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap