Re: Proposed changes to NodeIterator interface semantics

Mike Champion writes:
 > [...]
 > The "current" point of the iterator is before the node returned by
 > 	getNextNode(), not on a particular node.
 > 
 > Thus, the getCurrentNode() method is meaningless and should be removed.
 > 
 > We should also add atFirst() and atLast() methods to allow users to get
 > the functionality of the java.util.Enumeration interface's hasMoreElements()
 > method.
 > 
 > I believe that these changes address the concerns raised on the mailing list in
 > a fairly elegant way.  Please let us know if you agree, disagree, or have a
 > better suggestion.

I agree. It's a bit like "points" in emacs lisp...

In emacs lisp, the "current" character is the one to the right of the point (=
cursor).  Introducing a similar operation would provide a way to examine the
iterator's state without moving it (but I could live without if necessary).

A better name for atFirst and atLast might be "atBeginning" and "atEnd".  First
and Last seems to imply "first element" and "last element" resp., which is no
longer true.  Your prose already used those terms:

 > ... The NodeIterator, however, lets
 > the caller re-position the iterator to the beginning or
					      ^^^^^^^^^
 > the end of the set of Nodes ...
       ^^^

In addition, you may need an explicit disposal operation for iterators, or you
will have to depend on the availability of weak references (assuming a garbage
collected implementation language).  The reason is that each Node has to know
all iterators that are active on its children, in order to update their
position when elements are removed or new ones are inserted.  If iterators are
never finished, they will start piling up.

Greetings,
	Axel Wienberg.

Received on Friday, 10 April 1998 12:45:45 UTC