M
markww
Hi,
I have a class like:
class CStorage {
map<int, vector<CSomething> > m_mData;
CSomething *m_pLastUsed;
};
I'd like to keep a member that points exactly to the 'last used'
element in that m_mData member. I would want to do something like:
void CStorage::Access(int nIndex, int nElement)
{
m_pLastUsed = &m_mData[nIndex][nElement];
}
That is pretty useful but if I want to erase the last used element, how
would I find that in the map to erase it? I can't do something like:
void CStorage::EraseLastUsed()
{
m_mData.erase(m_pLastUsed);
}
Yeah, how can I do something like that? Maybe keep an iterator to the
last element instead of the type pointer to it?
Thanks
I have a class like:
class CStorage {
map<int, vector<CSomething> > m_mData;
CSomething *m_pLastUsed;
};
I'd like to keep a member that points exactly to the 'last used'
element in that m_mData member. I would want to do something like:
void CStorage::Access(int nIndex, int nElement)
{
m_pLastUsed = &m_mData[nIndex][nElement];
}
That is pretty useful but if I want to erase the last used element, how
would I find that in the map to erase it? I can't do something like:
void CStorage::EraseLastUsed()
{
m_mData.erase(m_pLastUsed);
}
Yeah, how can I do something like that? Maybe keep an iterator to the
last element instead of the type pointer to it?
Thanks