class Mng
{
public:
Mng();
//...
//m_Bs may be changed by memberfunctions of the class
//m_update may only be changed by Mng::Update and initialized empty
void Update(std::vector<B>& n, std::vector<B>& l);
private:
std::vector<B> m_Bs;
std::set<int> m_update;
};
//n should contain new added B's, l should contain lost B's
void Mng::Update(std::vector<B>& n, std::vector<B>& l)
{
std::vector<B>::iterator it = m_Bs.begin();
while(it!=m_Bs.end())
{
int id = it->Id();
BOOL e = it->Exists();
std::set<int>::iterator ut = m_update.find(id);
if(e && ut==m_update.end())
{
m_update.insert(id);
n.push_back(*it);
}
elseif (!e && ut!=m_update.end())
{
m_update.erase(id);
l.push_back(*it);
}
++it;
}
}
But it seems that ut is always m_update.end(). What's wrong?
There isn't enough information there to diagnose your problem, however I can guarantee
you that std::set<T>::find() works as long as T meets the requirements for a sequence
container (int does).