Container insertion and removal

Steven Schveighoffer schveiguy at yahoo.com
Sat Mar 6 18:38:43 PST 2010


Steve Teale Wrote:

> >> Sounds good?
> > 
> > How can softRemove not affect iterating ranges?  What if the range is
> > positioned on the element removed?
> > 
> > The only two containers that would support softInsert would be linked
> > list and sorted map/set.  Anything else might completely screw up the
> > iteration.  I don't see a lot of "generic" use for it.
> > 
> > Another option is to use a "mutation" field that is checked every chance
> > by the range.  If it changes, then the range is invalidated.
> > 
> > -Steve
> 
> Steve,
> 
> Wouldn't the soft things throw (or maybe just nudge) an exception if the 
> container was in a state where the soft option was not appropriate.
> 
> That would be the other way round to what you said, The container would 
> note when some range operation had a conflicting currency.

I think the point of soft functions is to not compile if they are not supported by the container.  Can you think of a way a container can have a soft option that is appropriate sometimes, but not others (thereby enabling a runtime option)?  I can't really see it, but maybe I'm missing it.

-Steve



More information about the Digitalmars-d mailing list