写一个C++ 程序,如何判断对于map中不同key,是否有重复的value?
展开全部
for(map<T,T>::iterator it = g_map.begin(); it != g_map.end(); it++)
{
for(map<T,T>::iterator it1 = g_map.begin();it1 != g_map.end(); it1++)
{
if(it->first != it1->first && it->second == it1->second)
return 1;
}
}
return 0;
{
for(map<T,T>::iterator it1 = g_map.begin();it1 != g_map.end(); it1++)
{
if(it->first != it1->first && it->second == it1->second)
return 1;
}
}
return 0;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
typedef map<uint32, CProConnectHandle*> mapConnectManager;
mapConnectManager m_mapConnectManager;
int count = 0;
for (mapConnectManager::iterator it = m_mapConnectManager.begin(); it != m_mapConnectManager.end(); ++it)
{ // store element in key_type object
mapConnectManager::key_type val = it->second->GetDeviceID();
for (mapConnectManager::iterator it2 = m_mapConnectManager.begin(); it2 != m_mapConnectManager.end(); ++it2)
{
mapConnectManager::key_type val2 = it->second->GetDeviceID();
if (val == val2) count++;
if (count >= 2) return;
}
}
mapConnectManager m_mapConnectManager;
int count = 0;
for (mapConnectManager::iterator it = m_mapConnectManager.begin(); it != m_mapConnectManager.end(); ++it)
{ // store element in key_type object
mapConnectManager::key_type val = it->second->GetDeviceID();
for (mapConnectManager::iterator it2 = m_mapConnectManager.begin(); it2 != m_mapConnectManager.end(); ++it2)
{
mapConnectManager::key_type val2 = it->second->GetDeviceID();
if (val == val2) count++;
if (count >= 2) return;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询