我已经声明了集合数组
std::set<md_core::Sample *> _SessionSet[MAX_SESSIONS];
现在我写了两个函数
void insertIntoTrdSessionSet(unsigned char index, md_core::Sample *sample)
{
_SessionSet[index].insert(sample);
}
bool removeFromTrdSessionSet(md_core::Sample *sample, unsigned char i = MAX_SESSIONS)
{
if(i != MAX_SESSIONS)
{
if(_SessionSet[i].erase(sample))
return true;
}
else
{
for(i = 0; i < MAX_SESSIONS ; i++)
{
if(_SessionSet[i].erase(sample))
{
return true;
}
}
}
return false;
}
现在我从集合中一一提取一个值并尝试删除,但它表明该值不存在于结构中
for(i = 0; i < MAX_SESSIONS ; i++)
{
if(i != pMsg->_Session)
{
std::set<Sample *>::iterator it = pSub->_SessionSet[i].begin();
for(;it != pSub->_SessionSet[i].end(); it++)
{
sample = *it;
//now call delete for the sample
if(!pSub->removeFromTrdSessionSet(sample, i))
{
logV(MD_WARN_MSG, "No such sample %d to delete from odrders map for session %u", sample, index);
}
}
}
}