public class BreadthFirstTreeCompositeIterator extends AbstractTreeCompositeIterator
TreeComposite
.
To use this, instantiate it with a root TreeComposite and use the standard
iterator commands, e.g.:
TreeComposite root;
// Set up your tree here...
Iterator iterator = new BreadthFirstTreeCompositeIterator(root);
while (iterator.hasNext()) {
TreeComposite child = iterator.next();
// Do something with the child tree here...
}
Constructor and Description |
---|
BreadthFirstTreeCompositeIterator(TreeComposite root)
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext() |
TreeComposite |
next()
Sub-classes should override this method and call it via
super.next() . |
remove
public BreadthFirstTreeCompositeIterator(TreeComposite root)
root
- The root TreeComposite that is the starting point for this
iterator.public boolean hasNext()
hasNext
in interface java.util.Iterator<TreeComposite>
hasNext
in class AbstractTreeCompositeIterator
public TreeComposite next()
AbstractTreeCompositeIterator
super.next()
. If AbstractTreeCompositeIterator.hasNext()
is false, this
method throws a NoSuchElementException
as specified in the
Iterator
API.next
in interface java.util.Iterator<TreeComposite>
next
in class AbstractTreeCompositeIterator
Iterator.next()