RE: Hello and NodeIterator Revisited

>I really like the way you put the ContainerIterator into the Node to
>model the "betweeness".  But instead of putting the NodeIterator into
>the ContainerNode, put a "point" into the list.  And then give that
>"point" to the NodeIterator.  Then you no longer have a reference in
>the ContainerNode to the NodeIterator so it can go out of scope now
>when the user is done with it and in the destructor you can tell it to
>remove it's "point" from the ContainerNode.  Then the NodeIterator just
>uses that "point" the same way it used itself previously to navigate
>within it's parent ContainerNode.  Of course, this just moves the
>issue of "release" into another object behind the scenes.  Does this
>not allow you to get rid of "release" in the NodeIterator interface?
>I have not implemented this, I could be missing something.

One of the main reasons for modeling an iterator to have betweeness
semantics is to deal with how that iterator behaves when the document is
modified while the iterator is 'active'.  I have done something similar to
placing a 'point' into the document for IE.  The concern I have, is how does
the iterator behave when the document is modified.  For example, consider
the following HTML fragment:

	X<B>*</B>Y

Consider the '*' character as the 'point' in the document.  Even though
there is an iterator underneath the bold tag, the DOM would report that
there are zero children for the bold.  Now, if one were to create and insert
a node (say, and italic node) as a new child of the bold node, you have two
options for updating the iterator:

	X<B>*<I></I></B>Y, or
	X<B><I></I>*</B>Y

The iterator could go to the left of the newly inserted node, or to the
right of it.  

Also, given my original example, what would happen to the iterator if the
bold node were removed from the tree.  Again, you have two options:

	X*Y, or
	XY

Stated in words: should the iterator remain in the document in which it was
inserted, or should it be associated with the subtree in which it currently
lives, and move with that subtree?

-	Eric

Received on Tuesday, 5 May 1998 16:24:26 UTC