S
sam
Hi,
Can anyone please tell me how to simplify the following list traversal code?
for (l_iter=l_peer_info.begin(); l_iter!=l_peer_info.end(); l_iter++) {
hm = &(*l_iter);
m_iter=l_iter->begin();
while (m_iter!=l_iter->end()) {
if ((*l_iter)["key"] == "value") {
l_iter = l_peer_info.erase(l_iter);
l_iter--;
break;
}
else
m_iter++;
if (m_iter->first == "index")
i = m_iter->second;
else if (m_iter->first == "rule")
rule = m_iter->second;
else if (m_iter->first == "rule2")
rule2 = m_iter->second;
else if (m_iter->first == "method")
method = m_iter->second;
else if (m_iter->first == "rule3")
rule3 = m_iter->second;
else if (m_iter->first == "rule4")
rule4 = m_iter->second;
else if (m_iter->first == "rule5")
rule5 = m_iter->second;
......
}
}
Thanks
Sam
Can anyone please tell me how to simplify the following list traversal code?
for (l_iter=l_peer_info.begin(); l_iter!=l_peer_info.end(); l_iter++) {
hm = &(*l_iter);
m_iter=l_iter->begin();
while (m_iter!=l_iter->end()) {
if ((*l_iter)["key"] == "value") {
l_iter = l_peer_info.erase(l_iter);
l_iter--;
break;
}
else
m_iter++;
if (m_iter->first == "index")
i = m_iter->second;
else if (m_iter->first == "rule")
rule = m_iter->second;
else if (m_iter->first == "rule2")
rule2 = m_iter->second;
else if (m_iter->first == "method")
method = m_iter->second;
else if (m_iter->first == "rule3")
rule3 = m_iter->second;
else if (m_iter->first == "rule4")
rule4 = m_iter->second;
else if (m_iter->first == "rule5")
rule5 = m_iter->second;
......
}
}
Thanks
Sam