public class SearchNodePreorderIterator
extends java.lang.Object
Iterates reverse preorder over the whole tree starting at a given Node
.
Instances of this class should always be used instead of recursive method
calls because they cause StackOverflowError
s even in small programs.
Attention: The iteration process does not take care of changes in the model. If the containment hierarchy changes during iteration it is possible that elements are left or visited multiple times. For this reason it is forbidden to change the model during iteration. But the developer has to take care about it.
Modifier and Type | Field and Description |
---|---|
private Node |
next
The next element or
null if no more elements exists. |
Constructor and Description |
---|
SearchNodePreorderIterator(Node start)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Checks if more elements are available.
|
Node |
next()
Returns the next
Node in the containment hierarchy. |
protected void |
updateNext()
Computes the next element and updates
next() . |
private Node next
null
if no more elements exists.public boolean hasNext()
true
has more elements, false
has not more elements.protected void updateNext()
next()
.