You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ra...@web.de on 2001/11/06 11:19:14 UTC

DepthFirstIterator

Hi all,
I have written a class, two related interfaces and a helper class that I find quite useful and wanted to publish somehow. The jakarta commons collections seems to me the right place to do so.
The depth first iterator is written to traverse a tree-like structure and can be used to perform an action on all nodes of a tree.

(See attached file: SingletonIterator.java)(See attached file: CompositionView.java)(See attached file: DepthFirstIterator.java)(See attached file: Composition.java)


What do you think?
Ralph
---------------------
email: Ralph.Wagner@web.de

________________________________________________________________
WEB.DE - das grosse Horoskop Gewinnspiel!
http://horoskop.web.de

Re: DepthFirstIterator

Posted by Juozas Baliuka <ba...@mwm.lt>.
if is usefull Iterator implementation, but implemented incorrectly, method
hasNext() in DepthFirstIterator has side effect  :

 public boolean hasNext() {
  while (!mStack.isEmpty() &&
           !(((Iterator) mStack.peek()).hasNext())) {
// this is a bug !!!
  mStack.pop();
  }
  return !mStack.isEmpty();
 }

----- Original Message -----
From: <Ra...@web.de>
To: <co...@jakarta.apache.org>
Sent: Tuesday, November 06, 2001 11:19 AM
Subject: DepthFirstIterator


> Hi all,
> I have written a class, two related interfaces and a helper class that I
find quite useful and wanted to publish somehow. The jakarta commons
collections seems to me the right place to do so.
> The depth first iterator is written to traverse a tree-like structure and
can be used to perform an action on all nodes of a tree.
>
> (See attached file: SingletonIterator.java)(See attached file:
CompositionView.java)(See attached file: DepthFirstIterator.java)(See
attached file: Composition.java)
>
>
> What do you think?
> Ralph
> ---------------------
> email: Ralph.Wagner@web.de
>
> ________________________________________________________________
> WEB.DE - das grosse Horoskop Gewinnspiel!
> http://horoskop.web.de


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>