示例#1
0
void UpdateItem(WORD32 dwKey, T2 &vec, T1 *pData)
{
	T1 *pInfo = NULL;
	SNMP_PERF_VEC_IT it;
	for(it = vec.begin(); it != vec.end(); it++)
	{
		if((*it).dwKey == dwKey)
		{
			pInfo = &(*it);
			check_paranullpt(pInfo);
			memset(pInfo, 0, sizeof(*pInfo));
			memcpy(pInfo, pData, sizeof(*pInfo));
			printf("updateitem, update data, key:%#x\n", dwKey);
			return;
		}
	}
	
	// pInfo = new T1();
	pInfo = &g_snmptest;
	check_paranullpt(pInfo);
	memset(pInfo, 0, sizeof(*pInfo));
	memcpy(pInfo, pData, sizeof(*pInfo));
	vec.push_back(*pInfo);
	printf("updateitem, create data, key:%#x, new addr:%p\n", dwKey, pInfo);

}
示例#2
0
void insertSort( T1& nums, T2& vecnum)
{
	for(auto lit = nums.begin(); lit!=nums.end(); lit++)
	{
		if(vecnum.size()==0) vecnum.push_back(*lit);
		else
		{
			auto vit = vecnum.begin(); //vector iterator
			while(*vit<*lit && vit!=vecnum.end())
				vit++;
			vecnum.insert(vit, *lit);
		}
	}
}