org.jscience.util
Class DepthFirstTreeIterator

java.lang.Object
  extended by org.jscience.util.DepthFirstTreeIterator
All Implemented Interfaces:
java.util.Iterator

public class DepthFirstTreeIterator
extends java.lang.Object
implements java.util.Iterator

Provides an iterator through all the children of tree including tree itself. This is an iterator over the tree elements, not the contents of the tree elements. You have to call getContents() over each element to get contents, or use the conveninece method.


Constructor Summary
DepthFirstTreeIterator(Tree tree)
          Create an Iterator from a tree.
 
Method Summary
 java.util.Iterator getContentsIterator()
          DOCUMENT ME!
 Tree getTree()
          DOCUMENT ME!
 boolean hasNext()
          Tests if this Iterator contains more elements.
 java.lang.Object next()
          Returns the next element of this Iterator if this Iterator object has at least one more element to provide.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DepthFirstTreeIterator

public DepthFirstTreeIterator(Tree tree)
Create an Iterator from a tree. The iterator is built at construction time. If you change the tree elements afterwards, the changes won't be reflected here.

Parameters:
tree - of objects on which to enumerate.
Method Detail

hasNext

public boolean hasNext()
Tests if this Iterator contains more elements.

Specified by:
hasNext in interface java.util.Iterator
Returns:
true if and only if this Iterator object contains at least one more element to provide; false otherwise.

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Returns the next element of this Iterator if this Iterator object has at least one more element to provide.

Specified by:
next in interface java.util.Iterator
Returns:
the next element of this Iterator.
Throws:
java.util.NoSuchElementException - if no more elements exist.

remove

public void remove()
Removes from the underlying collection the last element returned by the iterator (optional operation). This method can be called only once per call to next. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method.

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException - if the remove operation is not supported by this Iterator.

getContentsIterator

public java.util.Iterator getContentsIterator()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getTree

public Tree getTree()
DOCUMENT ME!

Returns:
DOCUMENT ME!