public class SearchNodePreorderIterator extends 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.
|
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()
.