RE: Walking the DOM (was: XML APIs)

At 05:21 PM 11/13/98 +0000, Miles Sabin wrote:
>John Cowan wrote,
>> Miles Sabin wrote:
>> > Even with a remove() operation on the iterator class, this
>> > will still cause serious problems, because i will be
>> > invalidated every time a node is removed via j.
>> 
>> Agreed.  But other solutions are hardly better, since they
>> involve using remove operations with at best O(log n) behavior.
>> 
>> 1) You can't win;
>> 
>> 2) You can't even break even.
>
>Yes you can ...
>
>We just have ultra simple iterators, and *document* the
>conditions under which they remain valid, and rely on
>programmers being smart enough to know when those
>conditions hold and when they don't, or being able to
>ensure they hold (with manual updates or synchronization,
>or whatever).
>

I completely agree with Miles on this.  As long as any gotchas are
well documented, it shouldn't be a problem.
People can always do index-based traversals using live NodeLists
if iterators seem too scary.

Regards,
-Claude Zervas

Received on Friday, 13 November 1998 18:25:05 UTC