On Wed, 01 Aug 2012 03:44:47 -0400, Ellery Newcomer <ellery-newco...@utulsa.edu> wrote:

Hello.

Today I was thinking about Java. Specifically, java.util.Iterator and the pattern

while(iter.hasNext()) {
        Object item = iter.next();
        if(predicate(item)) {
                iter.remove();
        }
}

You can do this in Java.

You can do this just as easy in dcollections:

foreach(bool doRemove, item; container)
{
   doRemove = predicate(item);
}

In fact, this little feature is one of the major reasons I wanted to create a collections library. Tango's container library was modeled after Doug Lea's (not the Java adaptation of it), and it did not include a way to remove during iteration.

-Steve

Reply via email to