i meet a problem when i try to erase a duplicate struct item in std::vector. first I define a struct.
typedef unsigned int uint32_t;
struct TokenTerm{
std::string value;
std::string type;
uint32_t start_pos;
uint32_t end_pos;
}
Then after several process I got a vector . and I define op :
struct equal4EntityTermSet
{
bool operator()(const TokenTerm&l_term, const TokenTerm&r_term)
{
if (l_term.type == r_term.type and l_term.norm_value ==
r_term.norm_value and l_term.start_pos == r_term.start_pos
and l_term.end_pos == r_term.end_pos )
{
return false;
}
return true;
}
};
Next, I try to remove the duplicate TokenTerm by insert each item in set.
for(it = _query_term.m_entities.begin();it!= _query_term.m_entities.end(); it++)
{
entSet.insert(*it);
}
_query_term.m_entities.clear();
for(itSet = entSet.begin(); itSet!=entSet.end(); itSet++)
{
_query_term.m_entities.push_back(*itSet);
}
finally, it words partly. I erase same duplicate item .but it still exist duplicate. Then I print those items , they do exactly same with others( I compare it and print the bool value)
Hope help.