commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@eurobell.co.uk>
Subject Re: [Collections][Submit] TreeNode and friends
Date Mon, 27 May 2002 18:19:26 GMT
From: Kief Morris <kief@bitbull.com>
> >I would rather keep the iterator on TreeNode. If there are only two
standard
> >ways to iterate then two methods would seem appropriate. But are there
more
> >than two ways??
>
> I favor a single iterator() method on the interface which returns the
nodes in an
> unspecified order. I'm ambivalent about having the specific breadth/depth
iterator
> methods on the Interface, but if it seems like there will be more than
that, forget
> it; keep just a single iterator() method and leave other options to
implementations
> rather than clutter the interface.
>
> There's nothing wrong with having a plain iterator() method even if
there's no
> default way it needs to be implemented; other Collection (non-List)
classes
> have iterators whose return order is unspecified.

Good argument. How about:

"iterator() returns an iterator over the tree including this node and all of
its children. For specificly ordered iterations, use the methods provided on
TreeUtils."

Thus we have an iterator() method on TreeNode and
depthFirstIterator(TreeNode) and breadthFirstIterator(TreeNode) methods on
TreeUtils.

The other related question is whether to use TreeIterator, or just Iterator.
TreeIterator really only provides a typecast nextNode() method. Is this
enough to justify its existence?

Stephen


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message