public abstract class AbstractTreeCompositeIterator extends java.lang.Object implements java.util.Iterator<TreeComposite>
TreeComposite
instances using Java's Iterator
interface. The
purpose of this class and any sub-classes is that iterating over a
TreeComposite should require something like the following code:
TreeComposite root;
// Set up your tree here...
Iterator iterator = new TreeCompositeIterator(root);
while (iterator.hasNext()) {
TreeComposite child = iterator.next();
// Do something with the child tree here...
}
Sub-classes should implement an iterative tree traversal algorithm instead of
a recursive one.Constructor and Description |
---|
AbstractTreeCompositeIterator(TreeComposite root)
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
hasNext() |
TreeComposite |
next()
Sub-classes should override this method and call it via
super.next() . |
void |
remove() |
public AbstractTreeCompositeIterator(TreeComposite root)
root
- The root TreeComposite that is the starting point for this
iterator.public abstract boolean hasNext()
hasNext
in interface java.util.Iterator<TreeComposite>
public TreeComposite next()
super.next()
. If hasNext()
is false, this
method throws a NoSuchElementException
as specified in the
Iterator
API.next
in interface java.util.Iterator<TreeComposite>
Iterator.next()
public void remove()
remove
in interface java.util.Iterator<TreeComposite>