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


C++ hash_map::erase方法代码示例

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


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

示例1: put

 void put(K key, T data) {
     LRUCacheEntry<K,T>* node = _mapping[key];
     if (node) {
         // refresh the link list
         detach(node);
         node->data = data;
         attach(node);
     } else {
         if ( _freeEntries.empty() ) {
             node = tail->prev;
             detach(node);
             _mapping.erase(node->key);
             node->data = data;
             node->key = key;
             _mapping[key] = node;
             attach(node);
         } else {
             node = _freeEntries.back();
             _freeEntries.pop_back();
             node->key = key;
             node->data = data;
             _mapping[key] = node;
             attach(node);
         }
     }
 }
开发者ID:WangGL1985,项目名称:boolan,代码行数:26,代码来源:lru.cpp

示例2: CheckIfHaveCreative

void AdGroupPool::CheckIfHaveCreative(hash_map<Ice::Long, AdGroupPtr> & group_pool) {
  for (hash_map<Ice::Long, AdGroupPtr>::iterator git = group_pool.begin(); git != group_pool.end();) {
    if (!git->second->HasCreatives()) {
//      MCE_DEBUG("AdGroupPool::Init --> because obj->HasCreatives is false so erase it  groupid = " << git->first);
      group_pool.erase(git++);
    } else{
      ++git;
    }
  }
}
开发者ID:bradenwu,项目名称:oce,代码行数:10,代码来源:AdCache.cpp

示例3: free

/*************************************************
* Function: * check_connect_timeout
* Description: * 检测长时间没反应的网络连接,并关闭删除
* Input: *
* Output: *
* Others: *
*************************************************/
void *check_connect_timeout(void* para)
{
    hash_map<int, sockStruct>::iterator it_find;
    for(it_find = sock_map.begin(); it_find!=sock_map.end(); ++it_find){
        if( time((time_t*)0) - (it_find->second).time > 120){                //时间更改


            free((it_find->second).recvBuf);
            sock_map.erase(it_find);

            close(it_find->first);
        }
    }

}
开发者ID:OnelongX,项目名称:handy,代码行数:22,代码来源:ettest.cpp

示例4: remove

	void remove (int id){
		if(act[id]){
			for(unsigned int i=0; i<acttimers.size(); i++){
				if(acttimers[i].id == id){	
					acttimers.erase(acttimers.begin()+i);	
					return;
				}
			}
		}
		else{
			for(unsigned int i=0; i<timers.size(); i++){
				if(timers[i].id == id){	
					timers.erase(timers.begin()+i);	
					return;
				}
			}
		}
		if(act.find(id) != act.end())
			act.erase(id);
	}
开发者ID:Dephon,项目名称:MapleStory_tms,代码行数:20,代码来源:Skills.cpp

示例5: parse_struct

void MltRuntime::parse_struct(json_t* v, const JsonPath& curPath,
		hash_map<string, JsonPath>& uuid_paths, int erase) throw(Exception)
{
	json_t* je = json_object_get(v, "uuid");
	if ( je && json_is_string(je) && strlen(json_string_value(je)) ) {
		string uuid = json_string_value(je);
		if (!erase) {
			if ( uuid_paths.find(uuid) != uuid_paths.end()) {
				throw_error_v(ErrorRuntimeJsonUUIDDup, "uuid dup:%s", uuid.c_str());
			}
			uuid_paths[uuid] = curPath;
		}
		else {
			uuid_paths.erase(string(uuid));
		}
	}

	void* it =  json_object_iter(v);
	while(it) {
		const char* k = json_object_iter_key(it);
		je = json_object_iter_value(it);
		it = json_object_iter_next(v, it);

		if ( json_is_object(je) && json_object_size(je) > 0 ) {
			JsonPath subPath(curPath);
			subPath.push_back(k);
			parse_struct(je, subPath, uuid_paths, erase);
		}
		else if (json_is_array(je) && json_array_size(je) > 0) {
			int sz = json_array_size(je);
			for ( int i=0; i<sz; i++ ) {
				json_t* ae = json_array_get(je, i);
				if ( json_is_object(ae) && json_object_size(ae) > 0 ) {
					JsonPath subPath(curPath);
					subPath.push_back(k, i);
					parse_struct(ae, subPath, uuid_paths, erase);
				}
			}
		}
	}
}
开发者ID:amongll,项目名称:AVFX,代码行数:41,代码来源:VEditMltRun.cpp

示例6: preOrder

int preOrder(Node* head, int sum, int preSum, int level, int &maxlen, hash_map<int, int> &sumMap)
{
	if (head == NULL)
		return maxlen;
	int curSum = preSum + head->value;
	if (sumMap.count(curSum - sum) == 1)
	{
		maxlen = (level - sumMap[curSum - sum]) > maxlen ? (level - sumMap[curSum - sum]) : maxlen;
	}
	if (sumMap.count(curSum) == 0)
	{
		sumMap.insert(make_pair(curSum, level));
	}
	maxlen = preOrder(head->left, sum, curSum, level + 1, maxlen, sumMap);
	maxlen = preOrder(head->right, sum, curSum, level + 1, maxlen, sumMap);
	if (level == sumMap[curSum])
	{
		sumMap.erase(curSum);
	}
	return maxlen;
}
开发者ID:lilisu,项目名称:liCodeGit,代码行数:21,代码来源:getTreeMaxLen.cpp

示例7: handle_message

/*
handle_message - 处理每个 socket 上的消息收发
*/
int handle_message(int new_fd)
{
    char buf[MAXBUF + 1];
    char sendbuf[MAXBUF+1];
    int len;
    /* 开始处理每个新连接上的数据收发 */
    bzero(buf, MAXBUF + 1);
    /* 接收客户端的消息 */
    //len = recv(new_fd, buf, MAXBUF, 0);



    int nRecvBuf = MAXRECVBUF; //设置为32K

    setsockopt(new_fd, SOL_SOCKET, SO_RCVBUF, ( const char* )&nRecvBuf, sizeof(int));
    len=recv(new_fd,&buf, MAXBUF,0);

    //--------------------------------------------------------------------------------------------

    //这块为了使用ab测试

    char bufSend[1000] = {0};
    sprintf(bufSend,"HTTP/1.0 200 OK\r\nContent-type: text/plain\r\n\r\n%s","Hello world!\n");
    send(new_fd,bufSend,strlen(buf),0);

    //--------------------------------------------------------------------------------------------


    if (len > 0){

        //printf ("%d接收消息成功:'%s',共%d个字节的数据\n", new_fd, buf, len);


        //hash-map


        hash_map<int, sockStruct>::iterator it_find;
        it_find = sock_map.find(new_fd);
        if(it_find == sock_map.end()){
            //新的网络连接,申请新的接收缓冲区,并放入map中

            //printf("new socket %d\n", new_fd);


            sockStruct newSockStruct;
            newSockStruct.time = time((time_t*)0);
            newSockStruct.recvBuf = (unsigned int*)malloc(1000);
            memset(newSockStruct.recvBuf, 0, 1000);
            strcat((char*)newSockStruct.recvBuf, buf);
            sock_map.insert(pair<int,sockStruct>(new_fd, newSockStruct));
        }else{
            //网络连接已经存在,找到对应的数据缓冲区,将接收到的数据拼接到数据缓冲区中

            //printf("socket %d exist!\n", it_find->first);


            (it_find->second).time = time((time_t*)0);                //时间更改

            char* bufSockMap = (char*)(it_find->second).recvBuf;    //数据存储


            strcat(bufSockMap, buf);
            //printf("bufSockMap:%s\n", bufSockMap);

        }


    }
    else {
        if (len < 0)
            printf ("消息接收失败!错误代码是%d,错误信息是'%s'\n",
                    errno, strerror(errno));
        else {
            //将socket从map中移除

            /*
            hash_map::iterator it_find;
            it_find = sock_map.find(new_fd);
            sock_map.erase(it_find);
            */
            printf("client %d quit!\n",new_fd);
        }
        //close(new_fd);

        return -1;
    }
    /* 处理每个新连接上的数据收发结束 */

    //关闭socket的时候,要释放接收缓冲区。

    hash_map<int, sockStruct>::iterator it_find;
    it_find = sock_map.find(new_fd);
    free((it_find->second).recvBuf);
    sock_map.erase(it_find);

    close(new_fd);
    return len;
//.........这里部分代码省略.........
开发者ID:OnelongX,项目名称:handy,代码行数:101,代码来源:ettest.cpp

示例8: select_remove_form_map

void select_remove_form_map( unsigned long socket ){
	if( socket <=0 ) return;
	select_sockets_hash_map.erase(socket);
}
开发者ID:jilieryuyi,项目名称:wing-php,代码行数:4,代码来源:wing_select_socket_map.c

示例9: if


//.........这里部分代码省略.........
	
	
	//Parameter Tracing
	//ARM_blx/ARM_blx1/ARM_blx2
	if(
		(ph.id==PLFM_ARM && (instruction.itype==ARM_bl || instruction.itype==ARM_blx1 || instruction.itype==ARM_blx2)) ||
		(ph.id==PLFM_MIPS && (instruction.itype==MIPS_jal || instruction.itype==MIPS_jalx))
	)
	{
		op_t operand;
		operand.type=o_reg;
		for(int reg=0;reg<5;reg++)
		{
			operand.reg=reg;
			hash_map <op_t,OperandPosition,OpTHashCompareStr>::iterator iter=OperandsHash.find(operand);
			if(iter!=OperandsHash.end())
			{
				OperandPosition SrcOperandPosition;
				SrcOperandPosition.Address=iter->second.Address;
				SrcOperandPosition.Index=iter->second.Index;

				OperandPosition DstOperandPosition;
				DstOperandPosition.Address=address;
				DstOperandPosition.Index=0;

				InstructionMap.insert(pair<OperandPosition,OperandPosition>(SrcOperandPosition,DstOperandPosition));

			}else
			{
				break;
			}
		}
	}

	//Operand Tracing
	for(int i=UA_MAXOP-1;i>=0;i--)
	{
		op_t *pOperand=&instruction.Operands[i];
		if(pOperand->type>0)
		{
			//o_mem,o_displ,o_far,o_near -> addr
			//o_reg -> reg
			//o_phrase,o_displ -> phrase
			//outer displacement (o_displ+OF_OUTER_DISP) -> value
			//o_imm -> value
			WriteToLogFile(gLogFile,"\tOperand %u: [%s%s] ",i,(Features[i]&CF_CHG)?"CHG":"",(Features[i]&CF_USE)?"USE":"");
			if(Features[i]&CF_USE)
			{
				hash_map <op_t,OperandPosition,OpTHashCompareStr>::iterator iter=OperandsHash.find(*pOperand);
				if(iter==OperandsHash.end())
				{
					op_t tmp_op;
					memset(&tmp_op,0,sizeof(op_t));
					tmp_op.type=o_reg;
					if(pOperand->type==o_displ)
					{
						tmp_op.reg=pOperand->reg;
						iter=OperandsHash.find(tmp_op);
						if(iter==OperandsHash.end())
						{
							tmp_op.reg=pOperand->phrase;
							iter=OperandsHash.find(tmp_op);
						}
					}else if(pOperand->type==o_phrase)
					{
						tmp_op.reg=pOperand->specflag1;
						iter=OperandsHash.find(tmp_op);
						if(iter==OperandsHash.end())
						{
							tmp_op.reg=pOperand->phrase;
							iter=OperandsHash.find(tmp_op);
						}
					}
				}
				if(iter!=OperandsHash.end())
				{
					OperandPosition SrcOperandPosition;
					SrcOperandPosition.Address=iter->second.Address;
					SrcOperandPosition.Index=iter->second.Index;

					OperandPosition DstOperandPosition;
					DstOperandPosition.Address=address;
					DstOperandPosition.Index=i;

					InstructionMap.insert(pair<OperandPosition,OperandPosition>(SrcOperandPosition,DstOperandPosition));
				}
			}

			if(Features[i]&CF_CHG) //Save to hash(addr,i,op_t)
			{
				OperandPosition operand_position;
				operand_position.Address=address;
				operand_position.Index=i;
				OperandsHash.erase(instruction.Operands[i]);
				WriteToLogFile(gLogFile,"Inserting %u\r\n",i);
				OperandsHash.insert(pair<op_t,OperandPosition>(instruction.Operands[i],operand_position));
			}
		}
	}
}
开发者ID:BwRy,项目名称:DarunGrim,代码行数:101,代码来源:IDAAnalysis.cpp

示例10: remove

	void remove (int id){
		if(timers.find(id) != timers.end())
			timers.erase(id);
	}
开发者ID:Dephon,项目名称:MapleStory_tms,代码行数:4,代码来源:Maps.cpp

示例11: calculateGraphs

unsigned BUDataStructures::calculateGraphs(const Function *F,
                                           std::vector<const Function*> &Stack,
                                           unsigned &NextID,
                                           hash_map<const Function*, unsigned> &ValMap) {
  assert(!ValMap.count(F) && "Shouldn't revisit functions!");
  unsigned Min = NextID++, MyID = Min;
  ValMap[F] = Min;
  Stack.push_back(F);

  // FIXME!  This test should be generalized to be any function that we have
  // already processed, in the case when there isn't a main or there are
  // unreachable functions!
  if (F->isDeclaration()) {   // sprintf, fprintf, sscanf, etc...
    // No callees!
    Stack.pop_back();
    ValMap[F] = ~0;
    return Min;
  }

  DSGraph* Graph = getOrFetchDSGraph(F);

  // Find all callee functions.
  std::vector<const Function*> CalleeFunctions;
  GetAllAuxCallees(Graph, CalleeFunctions);
  std::sort(CalleeFunctions.begin(), CalleeFunctions.end());
  std::vector<const Function*>::iterator uid = std::unique(CalleeFunctions.begin(), CalleeFunctions.end());
  CalleeFunctions.resize(uid - CalleeFunctions.begin());

  // The edges out of the current node are the call site targets...
  for (unsigned i = 0, e = CalleeFunctions.size(); i != e; ++i) {
    const Function *Callee = CalleeFunctions[i];
    unsigned M;
    // Have we visited the destination function yet?
    hash_map<const Function*, unsigned>::iterator It = ValMap.find(Callee);
    if (It == ValMap.end())  // No, visit it now.
      M = calculateGraphs(Callee, Stack, NextID, ValMap);
    else                    // Yes, get it's number.
      M = It->second;
    if (M < Min) Min = M;
  }

  assert(ValMap[F] == MyID && "SCC construction assumption wrong!");
  if (Min != MyID)
    return Min;         // This is part of a larger SCC!

  // If this is a new SCC, process it now.
  if (Stack.back() == F) {           // Special case the single "SCC" case here.
    DEBUG(errs() << "Visiting single node SCC #: " << MyID << " fn: "
	  << F->getName() << "\n");
    Stack.pop_back();
    DEBUG(errs() << "  [BU] Calculating graph for: " << F->getName()<< "\n");
    calculateGraph(Graph);
    DEBUG(errs() << "  [BU] Done inlining: " << F->getName() << " ["
	  << Graph->getGraphSize() << "+" << Graph->getAuxFunctionCalls().size()
	  << "]\n");

    if (MaxSCC < 1) MaxSCC = 1;

    // Should we revisit the graph?  Only do it if there are now new resolvable
    // callees or new callees
    GetAllAuxCallees(Graph, CalleeFunctions);
    if (CalleeFunctions.size()) {
      DEBUG(errs() << "Recalculating " << F->getName() << " due to new knowledge\n");
      ValMap.erase(F);
      return calculateGraphs(F, Stack, NextID, ValMap);
    } else {
      ValMap[F] = ~0U;
      return MyID;
    }
  } else {
    // SCCFunctions - Keep track of the functions in the current SCC
    //
    std::vector<DSGraph*> SCCGraphs;

    unsigned SCCSize = 1;
    const Function *NF = Stack.back();
    ValMap[NF] = ~0U;
    DSGraph* SCCGraph = getDSGraph(NF);

    // First thing first, collapse all of the DSGraphs into a single graph for
    // the entire SCC.  Splice all of the graphs into one and discard all of the
    // old graphs.
    //
    while (NF != F) {
      Stack.pop_back();
      NF = Stack.back();
      ValMap[NF] = ~0U;

      DSGraph* NFG = getDSGraph(NF);

      if (NFG != SCCGraph) {
        // Update the Function -> DSG map.
        for (DSGraph::retnodes_iterator I = NFG->retnodes_begin(),
               E = NFG->retnodes_end(); I != E; ++I)
          setDSGraph(I->first, SCCGraph);
        
        SCCGraph->spliceFrom(NFG);
        delete NFG;
        ++SCCSize;
      }
//.........这里部分代码省略.........
开发者ID:C0deZLee,项目名称:IntFlow,代码行数:101,代码来源:BottomUpClosure.cpp

示例12: erase

void _Catalog_locale_map::erase(int key)
{
    if (M)
        M->erase(key);
}
开发者ID:bencz,项目名称:OrangeC,代码行数:5,代码来源:message_facets.cpp


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