commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <>
Subject Re: [Collections][Submit] TreeNode and friends
Date Mon, 27 May 2002 18:19:26 GMT
From: Kief Morris <>
> >I would rather keep the iterator on TreeNode. If there are only two
> >ways to iterate then two methods would seem appropriate. But are there
> >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
> 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
> 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)
> 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

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

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?


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message