S
sam
Hi,
Can anyone tell me how to initialise list<HashMap> in STL?
I written the following function, but if the "key" is not in the hash
table, the return value causes:
"terminate called after throwing an instance of 'std::length_error'
what(): vector::reserve
Abort (core dumped)
"
The function I written is shown as follow:
HashMap Parser::find_rule(string key_name, string i)
{
list<HashMap>::iterator l_iter;
HashMap::iterator m_iter;
for (l_iter=l_rule.begin(); l_iter!=l_rule.end(); l_iter++) {
for (m_iter=l_iter->begin(); m_iter!=l_iter->end(); m_iter++) {
if (m_iter->first == key_name) {
if (i != "") {
if (m_iter->second == i)
return *l_iter;
}
else
return *l_iter;
}
}
}
return *l_iter;
}
Thanks
Sam
Can anyone tell me how to initialise list<HashMap> in STL?
I written the following function, but if the "key" is not in the hash
table, the return value causes:
"terminate called after throwing an instance of 'std::length_error'
what(): vector::reserve
Abort (core dumped)
"
The function I written is shown as follow:
HashMap Parser::find_rule(string key_name, string i)
{
list<HashMap>::iterator l_iter;
HashMap::iterator m_iter;
for (l_iter=l_rule.begin(); l_iter!=l_rule.end(); l_iter++) {
for (m_iter=l_iter->begin(); m_iter!=l_iter->end(); m_iter++) {
if (m_iter->first == key_name) {
if (i != "") {
if (m_iter->second == i)
return *l_iter;
}
else
return *l_iter;
}
}
}
return *l_iter;
}
Thanks
Sam