public class SearchNodeReversePreorderIterator
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 |
previous
The previous element or
null if no more elements exists. |
Constructor and Description |
---|
SearchNodeReversePreorderIterator(Node start)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasPrevious()
Checks if more elements are available.
|
protected Node |
lastLeaf(Node node)
Returns the last leaf node.
|
Node |
previous()
Returns the next
Node in the containment hierarchy. |
protected void |
updatePrevious()
Computes the previous element and updates
previous() . |
private Node previous
null
if no more elements exists.public boolean hasPrevious()
true
has more elements, false
has not more elements.public Node previous()
Node
in the containment hierarchy.Node
.protected void updatePrevious()
previous()
.