当前位置: 首页>>代码示例>>C++>>正文


C++ multimap::insert方法代码示例

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


在下文中一共展示了multimap::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: book

 bool book(int start, int end) {
     auto p = make_pair(start, end);
     if(isAlreadyBookingTwice(p))
         return false;
     auto it = intervals.insert(make_pair(p, end));
     if(it != intervals.begin()) {
         auto prevIt = prev(it);
         if(prevIt->second > start) {
             auto newOverlap = make_pair(start, min(prevIt->second, end));
             overlaps.insert(newOverlap);
         }
         it->second = max(prevIt->second, end);
     }
     auto nextIt = next(it);
     while(nextIt != intervals.end() && nextIt->first.first < end) {
         auto newOverlap = make_pair(nextIt->first.first,
                                     min(nextIt->first.second, end));
         overlaps.insert(newOverlap);
         nextIt->second = max(nextIt->second, end);
         nextIt = next(nextIt);
     }
     return true;
 }
开发者ID:Time1ess,项目名称:MyCodes,代码行数:23,代码来源:solution2.cpp

示例2: RayCast

bool CMesh::RayCast(VECTOR4D &RayOrigin, VECTOR4D &RayDir, multimap<float, INTERSECTIONINFO>& Faces) {
  unsigned long nFaces = (unsigned long)m_Indices.size() / 3;
  unsigned long nBaseIndex = 0;
  unsigned long nIntersectedFaces = 0;

  for (unsigned long iFace = 0; iFace < nFaces; iFace++) {
    VECTOR4D &V0 = m_Vertices[m_Indices[nBaseIndex + 0]].Position;
    VECTOR4D &V1 = m_Vertices[m_Indices[nBaseIndex + 1]].Position;
    VECTOR4D &V2 = m_Vertices[m_Indices[nBaseIndex + 2]].Position;
    VECTOR4D Intersection;

    if (RayCastOnTriangle(V0, V1, V2, RayOrigin, RayDir, Intersection)) {
      float dist = Magnity(Intersection - RayOrigin);
      INTERSECTIONINFO II;
      II.Face = iFace;
      II.LocalPosition = Intersection;
      Faces.insert(make_pair(dist, II));
      nIntersectedFaces++;
    }
    nBaseIndex += 3;
  }
  return nIntersectedFaces > 0;
}
开发者ID:Nazul,项目名称:MSC-CG_OpenGL,代码行数:23,代码来源:Mesh.cpp

示例3: preprocess

	void preprocess() {
		for (int i = 0; i < raw_heads.size(); i++) {
			raw_head_to_body.insert(pair<int,int>(toInt((Lit) raw_heads[i]), i));
		}

		for (int i = 0; i < raw_heads.size(); i++) {
			if (raw_posb[i].size() == 1 && raw_negb[i].size() == 0) {
				if (raw_head_to_body.count(toInt((Lit) raw_posb[i][0])) == 1) {
					int r = raw_head_to_body.find(toInt((Lit) raw_posb[i][0]))->second;
					raw_bl[i] = raw_posb[i][0];
					raw_posb[r].copyTo(raw_posb[i]);
					raw_negb[r].copyTo(raw_negb[i]);
					raw_heads[r] = bv_false;
				}
			}
		}

		for (int i = 0; i < raw_heads.size(); i++) {
			if (raw_heads[i] == bv_false) continue;
			getId(raw_heads[i]);
		}

	}
开发者ID:geoffchu,项目名称:chuffed,代码行数:23,代码来源:well-founded.c

示例4: evaluation_thread

void evaluation_thread(const std::string& proxy_ip, const std::string& proxy_port)
{
	qtk::time::qStopwatch sw;

	sw.start();
	ip::tcp::iostream stream;
	stream.connect(proxy_ip, proxy_port);
	stream << "GET http://www.google.com/intl/en_ALL/images/logo.gif HTTP/1.1\r\n"
	   << "HOST www.google.com\r\n" << "\r\n"
	   << std::flush; 

	std::string response_line;
	std::getline(stream, response_line);
	double time = sw.lap();

	if (response_line.find("200") != std::string::npos)
	{
		boost::mutex::scoped_lock lock(final_proxy_list_mutex);
		final_proxy_list.insert(make_pair(time, proxy_ip + ":" + proxy_port));
	}

	stream.close();
}
开发者ID:qiangd6,项目名称:QTK,代码行数:23,代码来源:cnproxy_checker.cpp

示例5: main

int main()
{
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    scanf("%d",&n);
    int rs=-1,d;
    for(int i=0;i<n;++i)
    {
        scanf("%d",&a[i]); 
        for(d=1;d<=100;++d)
        {
            ret=s.equal_range(a[i]-d);
            for(it=ret.first; it!=ret.second;++it)
            {   
                f[i][d]=max(f[i][d],f[(*it).second][d]+1);    
            }                  
            if(f[i][d]>rs) rs=f[i][d];
        }
        s.insert(pair<int,int>(a[i],i));
        
    }
    printf("%d",rs+1);
}
开发者ID:thucdx,项目名称:algorithm-solution,代码行数:23,代码来源:LEM5.cpp

示例6: RayCast

bool CMesh::RayCast(VECTOR4D &RayOrigin, VECTOR4D &RayDir, multimap<float, INTERSECTIONINFO> &Faces)
{
    unsigned long nFaces = m_Indexes.size() / 3;
    unsigned long nBaseIndex = 0;
    unsigned long nIntersectedFaces = 0;
    for (unsigned long iFace = 0; iFace < nFaces; ++iFace, nBaseIndex+=3)
    {
        VECTOR4D &V0 = m_Vertexes[m_Indexes[nBaseIndex]].Position;
        VECTOR4D &V1 = m_Vertexes[m_Indexes[nBaseIndex + 1]].Position;
        VECTOR4D &V2 = m_Vertexes[m_Indexes[nBaseIndex + 2]].Position;
        VECTOR4D Intersection;
        if (RayCastOnTriangle(V0, V1, V2, RayOrigin, RayDir, Intersection))
        {
            // Distancia entre el origen y esa interseccion
            float dist = Magnity(Intersection - RayOrigin);
            INTERSECTIONINFO II;
            II.Face = iFace;
            II.LocalPosition = Intersection;
            Faces.insert(make_pair(dist, II));
            ++nIntersectedFaces;
        }
    }
    return nIntersectedFaces != 0;
}
开发者ID:Kalabaza,项目名称:Graficas,代码行数:24,代码来源:Mesh.cpp

示例7: CasValueProcess

void CCacheThread::CasValueProcess(const multimap<unsigned int, string> &mapRequestValue, multimap<unsigned int, string> &mapStoredValue)
{
	CVS_XLOG(XLOG_DEBUG, "CCacheThread::%s\n", __FUNCTION__);
	multimap<unsigned int, string>::iterator itr;
	multimap<unsigned int, string>::const_iterator citr;
	for (citr=mapRequestValue.begin(); citr!=mapRequestValue.end(); ++citr)
	{
		itr = mapStoredValue.find(citr->first);
		if(itr==mapStoredValue.end()) 
		{
			mapStoredValue.insert(make_pair(citr->first, citr->second));
		}
		else
		{
			unsigned int dwStoreValue = atoi(itr->second.c_str());
			unsigned int dwNeedAddValue = atoi(citr->second.c_str());
			dwStoreValue += dwNeedAddValue;

			char szTemp[32] = {0};
			snprintf(szTemp, sizeof(szTemp), "%d", dwStoreValue);
			itr->second = szTemp;
		}
	}
}
开发者ID:victorzjl,项目名称:BPE,代码行数:24,代码来源:CacheThread.cpp

示例8: MergeFeed

void LiveFeed::MergeFeed(int uid, vector<vector<LiveFeedItem*> >& merge_feeds, multimap<Ice::Long, int>& order_by_time) const{  
  vector<int> update_times;
  map<pair<int, Ice::Long>, int> merge_index;
  for(int i=0; i<feeds_.size(); i++){
    LiveFeedItem* litem = const_cast<LiveFeedItem*>(&feeds_.at(i));
    map<pair<int, Ice::Long>, int>::iterator it = merge_index.find(make_pair<int, Ice::Long>(litem->VerAndSmallType(), litem->merge()));
    if(it != merge_index.end()){
      if(litem->MiniMergeType() == FeedMergeReplace ||
      (litem->MiniMergeType() == FeedMergeAppend && merge_feeds[it->second].size()>=5)){
        continue;  
      }
      merge_feeds[it->second].push_back(litem);
      //update_times[it->second] = litem->time_;
    }else{
        merge_feeds.push_back(vector<LiveFeedItem*>());
        merge_feeds.back().push_back(litem);
        update_times.push_back(litem->time_);
        merge_index.insert(make_pair<pair<int, Ice::Long>, int>(make_pair<int, Ice::Long>(litem->VerAndSmallType(), litem->merge()), merge_feeds.size()-1));
    }
  }
  for(size_t i=0; i<update_times.size(); i++){
    order_by_time.insert(make_pair<Ice::Long, int>(update_times.at(i), i));
  }
}
开发者ID:bradenwu,项目名称:oce,代码行数:24,代码来源:LiveFeedCache.cpp

示例9: Read_Data

/*
multimap<size_t,data> MapUser; //size_t无符号整数
std::multimap<size_t,data>::iterator itu;
multimap<size_t,AdData>MapAd;
using namespace std;
*/
void Read_Data(multimap<size_t,data> &MapUser,multimap<size_t,AdData> &MapAd,string strFileAddress)
{
    // ----------------------open file-----------------------------
    
    FILE *fp;
    const char* address = strFileAddress.c_str();
    fp = fopen(address,"r");
    if (fp == NULL) {
        cout << "can not open file" << endl;
    }
    
    // ----------------------read by line -----------------------------
    int size = 1024;
    char s[1024];
    int count = 0;
    while(fgets(s,size,fp) != NULL)
    {
        //fputs (s, stdout);
        
        int i = 0;
        char *ptr = NULL;
        char *ss = s;
        vector<char*>p;
        ptr = strtok(ss, "\t");
        
        
        while(ptr != NULL){
            //test.push_back(p);
            p.push_back(ptr);
            //cout << i << "=" << p[i] << endl;
            i++;
            ss = NULL;
            ptr = strtok(ss, "\t");
            
        }
        //cout <<0 << "=" << p[1]<< endl;
  
    // ----------------------insert the data -----------------------------
        
        unsigned long int temp = 0;
        data tempdata;
        AdData adtemp;
        vector<data> UserBase;
        vector<AdData>AdBase;
        size_t UserIndex  = 0;
        size_t AdIndex = 0;

    
        
        temp = atoi(p[11]);
        tempdata.Impression = atoi(p[1]);
        tempdata.AdID=atoi(p[3]);
        tempdata.Click=atoi(p[0]);
        tempdata.Depth=atoi(p[5]);
        
        tempdata.Position=atoi(p[6]);
        tempdata.QueryID=atoi(p[7]);
        
        
        tempdata.AdvertiserID = atoi(p[4]);
        tempdata.DescriptionID = atoi(p[10]);
        tempdata.KeywordID = atoi(p[8]);
        tempdata.TitleID = atoi(p[9]);
        tempdata.DisplayURL = p[2];
        
        
        
        adtemp.UserID=temp;
        adtemp.Click = atoi(p[0]);
        adtemp.Impression = atoi(p[1]);
        
        AdBase.push_back(adtemp);
        MapAd.insert(std::multimap<size_t,AdData>::value_type(tempdata.AdID,AdBase[AdIndex]));
        AdIndex++;
        
        UserBase.push_back(tempdata);
        MapUser.insert(std::multimap<size_t,data>::value_type(temp,UserBase[UserIndex]));
        UserIndex++;
        p.clear();
        
       // delete *p;
        
        //cout << "Read from file: " << s << endl;
        
        i = 0;
        count++;
        if(count % 1000000 ==0){
            cout << count << endl;
        }
        
    }

    //cout << test[11] << endl;
    //for (int j = 0; j < 1000; j++){
//.........这里部分代码省略.........
开发者ID:siqiyaoyao,项目名称:hw2,代码行数:101,代码来源:ReadDate.cpp

示例10: solver

/**
 * return public keys or hashes from scriptpubkey, for 'standard' transaction types.
 */
bool solver(const cscript& scriptpubkey, txnouttype& typeret, vector<vector<unsigned char> >& vsolutionsret)
{
    // templates
    static multimap<txnouttype, cscript> mtemplates;
    if (mtemplates.empty())
    {
        // standard tx, sender provides pubkey, receiver adds signature
        mtemplates.insert(make_pair(tx_pubkey, cscript() << op_pubkey << op_checksig));

        // moorecoin address tx, sender provides hash of pubkey, receiver provides signature and pubkey
        mtemplates.insert(make_pair(tx_pubkeyhash, cscript() << op_dup << op_hash160 << op_pubkeyhash << op_equalverify << op_checksig));

        // sender provides n pubkeys, receivers provides m signatures
        mtemplates.insert(make_pair(tx_multisig, cscript() << op_smallinteger << op_pubkeys << op_smallinteger << op_checkmultisig));

        // empty, provably prunable, data-carrying output
        if (getboolarg("-datacarrier", true))
            mtemplates.insert(make_pair(tx_null_data, cscript() << op_return << op_smalldata));
        mtemplates.insert(make_pair(tx_null_data, cscript() << op_return));
    }

    // shortcut for pay-to-script-hash, which are more constrained than the other types:
    // it is always op_hash160 20 [20 byte hash] op_equal
    if (scriptpubkey.ispaytoscripthash())
    {
        typeret = tx_scripthash;
        vector<unsigned char> hashbytes(scriptpubkey.begin()+2, scriptpubkey.begin()+22);
        vsolutionsret.push_back(hashbytes);
        return true;
    }

    // scan templates
    const cscript& script1 = scriptpubkey;
    boost_foreach(const pairtype(txnouttype, cscript)& tplate, mtemplates)
    {
        const cscript& script2 = tplate.second;
        vsolutionsret.clear();

        opcodetype opcode1, opcode2;
        vector<unsigned char> vch1, vch2;

        // compare
        cscript::const_iterator pc1 = script1.begin();
        cscript::const_iterator pc2 = script2.begin();
        while (true)
        {
            if (pc1 == script1.end() && pc2 == script2.end())
            {
                // found a match
                typeret = tplate.first;
                if (typeret == tx_multisig)
                {
                    // additional checks for tx_multisig:
                    unsigned char m = vsolutionsret.front()[0];
                    unsigned char n = vsolutionsret.back()[0];
                    if (m < 1 || n < 1 || m > n || vsolutionsret.size()-2 != n)
                        return false;
                }
                return true;
            }
            if (!script1.getop(pc1, opcode1, vch1))
                break;
            if (!script2.getop(pc2, opcode2, vch2))
                break;

            // template matching opcodes:
            if (opcode2 == op_pubkeys)
            {
                while (vch1.size() >= 33 && vch1.size() <= 65)
                {
                    vsolutionsret.push_back(vch1);
                    if (!script1.getop(pc1, opcode1, vch1))
                        break;
                }
                if (!script2.getop(pc2, opcode2, vch2))
                    break;
                // normal situation is to fall through
                // to other if/else statements
            }

            if (opcode2 == op_pubkey)
            {
                if (vch1.size() < 33 || vch1.size() > 65)
                    break;
                vsolutionsret.push_back(vch1);
            }
            else if (opcode2 == op_pubkeyhash)
            {
                if (vch1.size() != sizeof(uint160))
                    break;
                vsolutionsret.push_back(vch1);
            }
            else if (opcode2 == op_smallinteger)
            {   // single-byte small integer pushed onto vsolutions
                if (opcode1 == op_0 ||
                    (opcode1 >= op_1 && opcode1 <= op_16))
                {
//.........这里部分代码省略.........
开发者ID:moorecoin,项目名称:MooreCoinMiningAlgorithm,代码行数:101,代码来源:standard.cpp

示例11: addWeight

	void addWeight(const K& key, const C& cost)
	{
		auto const weight = w_.calculate(t_.getTimestamp(), cost);
		keyWeightMap_.insert( make_pair(key, weight) );
		weightKeyMap_.insert( make_pair(weight, key) );
	}
开发者ID:PavPS,项目名称:Careercup,代码行数:6,代码来源:Amazone14.cpp

示例12: parseOptsIntoMultiMap

void parseOptsIntoMultiMap(vector<OptStruct>& opts,multimap<string,string>& optmap){
	for(vector<OptStruct>::iterator i=opts.begin();i!=opts.end();i++)
		optmap.insert(multimap<string,string>::value_type(i->opname,i->opvalue));
}
开发者ID:albertwcheng,项目名称:clustergram,代码行数:4,代码来源:AdvGetOpt.cpp

示例13: inser

void inser(char ch,int num)
{

  mymm.insert(pair<char,int>(ch,num));
}
开发者ID:Naresh-Nelavalli,项目名称:Practice-programs,代码行数:5,代码来源:DictionaryA-Z.cpp

示例14: DownroadFile


//.........这里部分代码省略.........
			cout<<"open zip file "<<ofs_gzip_name.c_str()<<" error ."<<endl;
			exit(-1);

		}

		//解压缩过程,将解压缩后的网页体信息放入到缓冲区域unzip_content_buffer
		unzip_length = gzread(zip,unzip_content_buffer,1024000);
		if(unzip_length == -1)
		{
			cout<<"read zip file "<<ofs_gzip_name.c_str()<<" error ."<<endl;
			exit(-1);
		}

		unzip_content_buffer[unzip_length] = 0;
		gzclose(zip);
	}//解压缩过程结束

	*/
	CMD5 imd5;
	string str_digest;

	//判断该URL是否在set_visited_url_md5中,在返回;不在加到其中,并保存
	imd5.GenerateMd5((unsigned char *)iurl.origin_url.c_str(),iurl.origin_url.length());//生成md5码
	str_digest = imd5.ToString();

	WaitForSingleObject(mutex_visited_url_md5,INFINITE);

	if(set_visited_url_md5.find(str_digest) != set_visited_url_md5.end())//表明已经抓取过
	{
		cout<<"the url :"<<iurl.origin_url.c_str()<<" have crawled !"<<endl;

		ReleaseMutex(mutex_visited_url_md5);
		return ;
	}

	//不在set_visited_url_md5中,现在必须插入set_visited_url_md5中
	//因为该URL现在已经访问过了
	set_visited_url_md5.insert(str_digest);
	SaveVisitedUrlMd5(str_digest);
	ReleaseMutex(mutex_visited_url_md5);

	//判断该网页体是否已经访问过,访问过返回,没有访问过加到set_visited_page_md5集合中
	imd5.GenerateMd5((unsigned char *)ipage.body_content.c_str(),ipage.body_content.length());
	str_digest = imd5.ToString();

	WaitForSingleObject(mutex_visited_page_md5,INFINITE);
	//网页体MD5同URL的关系插入到容器replicas中
	replicas.insert(pair<string,string>(str_digest,iurl.origin_url));

	if(set_visited_page_md5.find(str_digest) != set_visited_page_md5.end())//表明出现了镜像文件
	{
		cout<<"the page  have crawled !"<<endl;

		ReleaseMutex(mutex_visited_page_md5);
		return ;
	}

	//不在set_visited_page_md5中,现在必须插入set_visited_page_md5中
	//因为该URL现在已经访问过了
	set_visited_page_md5.insert(str_digest);
	SaveVisitedPageMd5(str_digest);
	ReleaseMutex(mutex_visited_page_md5);
	

	//将抓取到的网页以PSE格式放到原始网页库中
	SavePseRawData(pse_file_ptr,&iurl,&ipage);

	if(ipage.location.length()<1)
	{
		SaveVisitedUrl(iurl.origin_url);
	}
	else
		SaveVisitedUrl(ipage.location);

	if(ipage.content_type != "text/html")//只可以在text/html中发现超链接
		return ;

//=====================================保存单个网页的所有连接信息

	if (ipage.ParseHyperLinks() == false)
	{
		return;
	}
	
	SaveLinkForPSE( &ipage);
	SaveLinkForHistory( &ipage);

	map<string,string>::iterator it = ipage.map_link_for_pse.begin();
	string str;
	for( ; it!= ipage.map_link_for_pse.end(); ++it )
	{
		str = (*it).first;
		AddUrl( str.c_str() );

	}

//========================================

	return ;
}
开发者ID:TimmaWang,项目名称:PictureCrawl,代码行数:101,代码来源:Crawl.cpp

示例15: read_module_symbols


//.........这里部分代码省略.........

    // Determine the full path to the module based on the base image path.
    // Assumes they are in the same subdirectory.
    string module_path = g_imageName.substr(0, g_imageName.rfind('/') + 1) +
                         module;

    // Create the 'objdump' command for finding all the symbols and start as
    // a sub-process.
    string command = string(g_crossPrefix) + string("objdump --syms -C ") +
                     module_path;
    FILE* pipe = popen(command.c_str(), "r");
    if (NULL == pipe) return NULL;

    // Local symbol map (to reduce contention on the global symbol map).
    //   No need to use the overhead of a map because we don't care about
    //   order at this point.
    vector<pair<uint64_t, string> > l_symbols;

    // Parse each line of the 'objdump' output.
    char line[1024];
    do
    {
        if (NULL == fgets(line, 1024, pipe)) break;

        size_t linelen = strlen(line);

        // Skip absolute values (ex. constants) and undefined symbols.
        if (strstr(line, "*ABS*") || strstr(line, "*UND*")) continue;
        // Skip section symbols (marked by 'd' in the 22nd column).
        if (linelen > 22 && 'd' == line[22]) continue;

        // First part of an objdump line is the symbol address, parse that.
        uint64_t line_address;
        if (1 != sscanf(line, "%16lx", &line_address)) continue;
        line_address += addr;

        // Determine if the symbol is a function and if it is in the .rodata
        // section.  Symbols in the .rodata section have a slightly longer
        // line than those in the .text/.data sections (by 2 characters).
        bool is_function = (linelen > 23 && 'F' == line[23]);
        size_t rodata = (NULL != strstr(line, ".rodata")) ? 2 : 0;

        // Parse the symbol size.
        uint64_t symbol_size;
        if (linelen > 32+rodata &&
            1 != sscanf(&line[32+rodata], "%lx", &symbol_size)) continue;

        // Parse the function name.
        assert(linelen > 48+rodata);
        string function = &line[48+rodata];
        function.resize(function.length() - 1); // remove the newline.

        // Function have two addresses: TOC entry and code address.  Objdump
        // gives the TOC entry, so we need to read the file itself to determine
        // the code address.  The first part of the TOC entry is the code
        // address.
        uint64_t code_addr = 0;
        if (is_function)
        {
            // Module is in the extended image, read from it.
            if (line_address > g_extImageOffset)
            {
                // Read code address.
                assert((line_address - g_extImageOffset) < g_extImageFileSize);
                memcpy(&code_addr,
                       &g_extImageFile[line_address - g_extImageOffset], 8);
            }
            // Module is in the base image.
            else
            {
                // Read code address.
                assert(line_address < g_imageFileSize);
                memcpy(&code_addr, &g_imageFile[line_address], 8);
            }
            // Fix up the endianness.
            code_addr = be64toh(code_addr);

            std::swap(code_addr, line_address);
        }

        // Print all of this into a new line and add to the symbol map.
        sprintf(line, "%c,%08lx,%08lx,%08lx,%s\n",
            is_function ? 'F' : 'V',
            line_address, code_addr, symbol_size,
            function.c_str());

        l_symbols.push_back(make_pair(line_address, line));

    } while(1);

    // Close subprocess (done).
    pclose(pipe);

    // Copy our local symbol list all at once into the global symbol list.
    pthread_mutex_lock(&g_symbolMutex);
    g_symbols.insert(l_symbols.begin(), l_symbols.end());
    pthread_mutex_unlock(&g_symbolMutex);

    return NULL;
}
开发者ID:open-power,项目名称:hostboot,代码行数:101,代码来源:gensyms.C


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