public class ExecutionNodePreorderIterator
extends java.lang.Object
Iterates preorder over the whole sub tree of a given IExecutionNode
.
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 IExecutionNode<?> |
next
The next element or
null if no more elements exists. |
private IExecutionNode<?> |
start
The element at that the iteration has started used as end condition
to make sure that only over the subtree of the element is iterated.
|
Constructor and Description |
---|
ExecutionNodePreorderIterator(IExecutionNode<?> start)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected IExecutionNode<?> |
getNextOnParent(IExecutionNode<?> node)
Returns the next element to select if all children of the given
IExecutionNode are visited. |
boolean |
hasNext()
Checks if more elements are available.
|
IExecutionNode<?> |
next()
Returns the next
IExecutionNode in the containment hierarchy. |
protected void |
updateNext()
Computes the next element and updates
next() . |
private IExecutionNode<?> start
private IExecutionNode<?> next
null
if no more elements exists.public ExecutionNodePreorderIterator(IExecutionNode<?> start)
start
- The IExecutionNode
to iterate over its sub tree.public boolean hasNext()
true
has more elements, false
has not more elements.public IExecutionNode<?> next()
IExecutionNode
in the containment hierarchy.IExecutionNode
.protected void updateNext()
next()
.protected IExecutionNode<?> getNextOnParent(IExecutionNode<?> node)
IExecutionNode
are visited.node
- The visited IExecutionNode
.IExecutionNode
to visit.