就顺序读取map中的每个key,当遇到一个key都放到一个数组中标记次数,然后看有没有大于1的,就知道是否有重复的value了
for(map
{
for(map
{
if(it->first != it1->first && it->second == it1->second)
return 1;
}
}
return 0;
typedef map
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;
}
}