Subject: Re: libprop iterators
To: Chapman Flack <firstname.lastname@example.org>
From: Jason Thorpe <email@example.com>
Date: 06/06/2006 09:29:28
On Jun 6, 2006, at 7:33 AM, Chapman Flack wrote:
> libprop iterators currently have the (reasonable) restriction that
> become invalid if a structure-changing operation (removal or
> occurs on the underlying collection. Once the iterator is invalidated,
> iteration has to restart at the beginning.
Yes, this was modeled after how iterators work in Foundation in OS
X. You're not allowed to mutate a mutable collection while iterating
> Java provided for that use by giving each iterator a remove() method
> that simply removes from the collection that most recent object the
> iterator returned, and keeps that iterator synchronized. (Any other
> active iterators are still invalidated, of course.)
> Even if the collection is so small you don't care about the
> performance, it still helps keep the code concise:
> while ( e = it.next() ) if ( e.isdead() ) it.remove();
> is just nicer to read than any of the alternatives.
> Would any object if I were to add such a method to libprop iterators?
> It looks to take very few LOC.
I'm not fundamentally opposed to such a thing. I just don't really
like operating on an implicit "last object".
If you want to cook up a patch, that's fine with me. Please post it
here for review first. Please call the new function