I’m trying to do the following without too much special case code to deal with invalidated POSITIONs etc:
What’s the best way to fill in the blanks?
void DeleteUnreferencedRecords(CAtlMap<Record>& records) { for(____;____;____) { if( NotReferencedElsewhere(record) ) { // Delete record _______; } } }
According to this:
http://msdn.microsoft.com/en-us/library/0h4c3zkw(VS.80).aspx
RemoveAtPos has these semantics
The problem is that the order can change — which means that GetNext() won’t really continue the iteration. It looks like you need to collect the POSITIONs you want to delete in one pass and delete them in the next. Removing a POSITION does not invalidate the other POSITION objects