W3C home > Mailing lists > Public > www-dom@w3.org > April to June 1998

Re: Proposed changes to NodeIterator interface semantics

From: Axel Wienberg <awienber@hoxsun05.higher-order.de>
Date: Fri, 10 Apr 1998 18:42:40 +0200
Message-Id: <199804101642.SAA27407@hoxsun05.higher-order.de>
To: www-dom@w3.org

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:45 GMT