Re: Iterators and removing

Hi Michael,


>At 06:21 AM 4/2/98 -0500, Axel Wienberg wrote:
>>
>>Hi,
>>
>>I've got a question on the behaviour of NodeIterators.  What is supposed
to
>>happen if the current node of an iterator is removed from its parent?

<snipped other stuff>

>We discussed this in the IG recently; I'm not sure if we reached a
>consensus.  My position is that if one removes a node that an iterator
>points to, the "current" node becomes undefined and the getCurrent() method
>should throw an exception, and toNext() and toPrevious() would return the
>values that would have been returned had the node not been deleted.  In
>other words, I imagine the iterator pointing to the empty spot where the
>current node WAS; since there is no node there, "current" is undefined, but
>next and previous are.

I think I like this idea better than the ones I suggested earlier.  A couple
of clarifying questions:

Should there be any way to test whether this has happened, other than
calling getCurrent and catching an Exception?  I guess the user will know if
this has happened and should simply take it into account.

If the removed node was the last one in the list, I assume null would be
returned and the NodeIterator would be pointing to the previous Node, which
is now the last one on the list.

>
>I think the alternatives are confusing for users and challenging for
>implementors, and don't add anything in the way of conceptual integrity.
>

Thanks,

David

Received on Friday, 3 April 1998 20:29:33 UTC