如何通过第二个映射第二个节点迭代并查找重复项? 使用下面的代码我期望第二个 for循环迭代4次,因为外部地图中有4个节点。但是,在第二次 for循环的第一次迭代之后,我得到了一个段错误。和想法?
void xmlParser::SortAndGroupByKey()
{
bool match = true;
std::map<std::vector<unsigned char>, std::vector<unsigned char>> tempMidNonceMap;
std::map<std::vector<unsigned char>, std::vector<unsigned char>>::iterator keyIt= m_mapMidNonceKey.begin()->second.begin();
//Iterate thru the second maps second element
for(std::map<std::vector<unsigned char>, std::map<std::vector<unsigned char>, std::vector<unsigned char>>>::iterator mapIt=m_mapMidNonceKey.begin(); mapIt != m_mapMidNonceKey.end(); ++mapIt)
{
//innerMapit points to the inner(2nd Map) map iterator
for(std::map<std::vector<unsigned char>, std::vector<unsigned char>>::iterator innerMapit= mapIt->second.begin(); innerMapit != mapIt->second.end(); ++innerMapit)
{
for(size_t i = 0; i < innerMapit->second.size(); ++i)
{
if(innerMapit->second[i] != keyIt->second[i]) //Do they match?
{
match = false;
break;
}
}
if(match)
{
//Make a pair of the values
tempMidNonceMap.insert(std::make_pair(mapIt->first,innerMapit->first));
}
}
//Check to see if the key already exists in the map if it does then only insert
if(!DuplicateKeyExists(keyIt->second))
{
this->m_mapKey.insert(std::make_pair(keyIt->second, tempMidNonceMap));
}
tempMidNonceMap.clear();
keyIt++;
match = true;
}
}
答案 0 :(得分:0)
已解决:地图地图的格式不是我“想到的”我正在填充它。我在地图上添加了许多较小的地图。
答案 1 :(得分:0)
您可能使用
进行了超出限制的访问if (idRequisicion > 0) {
function MostrarInformacion(fn, tiempo) {
var dfd = $.Deferred();
setTimeout(function () {
dfd.resolve(fn());
}, tiempo || 0);
return dfd.promise();
}
var promise = MostrarInformacion(function () {
$.blockUI({
css: {
border: 'none',
padding: '0',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff',
onBlock: $.when(CargarDetalles()).done(MostrarDetalles)
}
});
setTimeout($.unblockUI, 2000);
}, 300);
}
代表innerMapit->second[i] != keyIt->second[i]
最简单的解决方法应该是使用
keyIt->second[i]
而不是
const bool match = (innerMapit->second != keyIt->second);