roxen.lists.pike.general

Subject Author Date
Re: Iterators and deleting entries from mappings Stephen R. van den Berg <srb[at]cuci[dot]nl> 15-01-2009
Martin B?hr wrote:
>On Thu, Jan 15, 2009 at 11:35:05AM +0100, Martin Stjernholm wrote:
>> > In Pike 7.8, what is supposed to happen when you use an iterator on
>> > a mapping, and then while iterating you delete entries from the mapping?
>> If the mapping changes while being iterated, the iterator might miss
>> elements, but it should not visit the same element more than once, and
>> if an element is present during the whole iteration then it should not
>> be missed. (Value changes in elements are irrelevant.)

>so if elements are added while the mapping being iterated,
>they might be missed, but deleting one element can't cause another
>element to be missed. (because obviously it is present for the whole
>iteration)

>so it is only unclear what happens to new elements.
>(would there be any benefit to change that?)

This behaviour is perfect.  It is exactly what I would expect, and therefore
there would be zero benefit to me to change that behaviour.
-- 
Sincerely,
           Stephen R. van den Berg.
The ultimate Darwin Award winner:
Going first in a Russian roulette game with a normal gun (no revolver).