Re: containers, iteration, and removal

2012-08-27 Thread Steven Schveighoffer
On Fri, 24 Aug 2012 13:35:57 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: foreach(bool doRemove, item; container) { doRemove = predicate(item); } Whoops, should be foreach(ref bool doRemove, item; container) -Steve

Re: containers, iteration, and removal

2012-08-27 Thread Ellery Newcomer
On 08/27/2012 06:27 AM, Steven Schveighoffer wrote: On Fri, 24 Aug 2012 13:35:57 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: foreach(bool doRemove, item; container) { doRemove = predicate(item); } Whoops, should be foreach(ref bool doRemove, item; container) -Steve Right,

Re: containers, iteration, and removal

2012-08-27 Thread Ellery Newcomer
On 08/24/2012 12:23 PM, JN wrote: I feel kinda stupid here, what's wrong with C++ remove_if ( http://www.cplusplus.com/reference/algorithm/remove_if/ )? you mean something like c.erase(remove_if(c.begin(), c.end(), predicate), c.end()) ? That actually is the sort of thing one could

Re: containers, iteration, and removal

2012-08-27 Thread Ellery Newcomer
On 08/27/2012 12:46 PM, Ellery Newcomer wrote: On 08/24/2012 12:23 PM, JN wrote: I feel kinda stupid here, what's wrong with C++ remove_if ( http://www.cplusplus.com/reference/algorithm/remove_if/ )? you mean something like c.erase(remove_if(c.begin(), c.end(), predicate), c.end()) ? That

Re: containers, iteration, and removal

2012-08-24 Thread Steven Schveighoffer
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)) {

Re: containers, iteration, and removal

2012-08-24 Thread JN
I feel kinda stupid here, what's wrong with C++ remove_if ( http://www.cplusplus.com/reference/algorithm/remove_if/ )?

containers, iteration, and removal

2012-08-01 Thread Ellery Newcomer
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. Easily. You can also do this in C++ with

Re: containers, iteration, and removal

2012-08-01 Thread monarch_dodra
On Wednesday, 1 August 2012 at 07:44:49 UTC, Ellery Newcomer wrote: I also take (erk) issue with the implementation of linearRemove. It depends on an interface from the container range that is not part of the general range interface. This poses problems. You can't wrap the container range with