iterator stability for containers

ikod igor.khasilev at gmail.com
Wed Sep 23 07:14:45 UTC 2020


On Monday, 21 September 2020 at 21:27:38 UTC, Daniel Kozak wrote:
> On Mon, Sep 21, 2020 at 11:05 PM ikod via Digitalmars-d < 
> digitalmars-d at puremagic.com> wrote:
>
>> Sorry, do you mean - the sources were lost?
>>
>
> http://www.dsource.org/projects/dcollections
>
>
>> > Honestly, my impetus for creating dcollections was to 
>> > reproduce some of the nice features of iterators in C++, 
>> > including removal while iterating.
>>
>> Agree totally.
>>
>> I have problems with stable and performant iterator over 
>> unrolled linked list, so I'm looking around for available 
>> solutions.
>>
>
> From my POV I`m ok even with containers where stability is not 
> provide. But

Sometimes we need to operate on collection while we iterate over 
it, and it's pity if you have to collect this changes somewhere 
and then apply in separate action.

> it would be perfect to have containers when I can select between
> performance or stability.

Performance (in terms of execution speed) is also first priority 
for me.
I can give up some small part of speed in exchange for 
convenience only when user make some unusual and rare things 
(like updating collection while iterating over it)


> I hardly ever need stability from containers, so for me it 
> would be ok to
> not guarantee in favor of speed. But still would be nice to 
> have a way to
> say that in some cases I prefer stability

It is possible to make stability configurable.




More information about the Digitalmars-d mailing list