News for hackers. Stuff that matters.
Re:What's wrong with this code, really? by sunir on Friday September 16, 2011 @01:54PM (#3005507)
The correct idiom is delete list head until list is empty.

The iterator may become invalid if the collection it derived from changes.

Iterator delete methods are crazy to begin with since iteration does not correlate with deletion. But anyway it is not clear where the iterator's cursor will point after you delete the current element. You could end up deleting every second element in the container.

Re:What's wrong with this code, really? by morsch on Wednesday September 21, 2011 @10:05AM (#3022018)
My example wasn't clearing the list, it's a filter. And depending on what language and library you're talking about, it's very clear where the cursor will point to after a delete. There's nothing crazy about it with an even halfway sane collection framework.