Class AbstractBroadFirstTreeIterator<P extends IterableNode<? extends C>,C extends IterableNode<?>>
- java.lang.Object
-
- org.arakhne.afc.math.tree.iterator.AbstractBroadFirstTreeIterator<P,C>
-
- Type Parameters:
P
- is the type of the parent nodes.C
- is the type of the child nodes.
- All Implemented Interfaces:
Iterator<P>
- Direct Known Subclasses:
BroadFirstTreeIterator
public abstract class AbstractBroadFirstTreeIterator<P extends IterableNode<? extends C>,C extends IterableNode<?>> extends Object implements Iterator<P>
This class is an iterator on a tree.The node A is treated before its children.
- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:41
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathtree
-
-
Constructor Summary
Constructors Constructor Description AbstractBroadFirstTreeIterator(P node)
Create an iterator on the given node.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BroadFirstIterationListener
getBroadFirstIterationListener()
Replies the listener invoked when a level of the tree has been treated.boolean
hasNext()
P
next()
protected void
onAfterChildNodes(P node, int childCount)
Invoked after all the children of a node were memorized by the iterator.protected void
onBeforeChildNodes(P node)
Invoked before all the children of a node were memorized by the iterator.protected void
onBoardFirstIterationLevelFinished()
Invoked when a row of tree nodes was completely replied by the iterator.void
remove()
void
setBroadFirstIterationListener(BroadFirstIterationListener listener)
Set the listener invoked when a level of the tree has been treated.protected abstract P
toTraversableChild(P parent, C child, int childIndex, int notNullChildIndex)
Replies an object to type N which is corresponding to the given child node retreived from the given parent node.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
AbstractBroadFirstTreeIterator
public AbstractBroadFirstTreeIterator(P node)
Create an iterator on the given node.- Parameters:
node
- is the node to iterate.
-
-
Method Detail
-
setBroadFirstIterationListener
public void setBroadFirstIterationListener(BroadFirstIterationListener listener)
Set the listener invoked when a level of the tree has been treated.- Parameters:
listener
- the listener.
-
getBroadFirstIterationListener
@Pure public BroadFirstIterationListener getBroadFirstIterationListener()
Replies the listener invoked when a level of the tree has been treated.- Returns:
- the listener
-
onBoardFirstIterationLevelFinished
protected void onBoardFirstIterationLevelFinished()
Invoked when a row of tree nodes was completely replied by the iterator.
-
onAfterChildNodes
protected void onAfterChildNodes(P node, int childCount)
Invoked after all the children of a node were memorized by the iterator.- Parameters:
node
- is the node for which all the child nodes have been memorized.childCount
- is the number of child nodes that are memorized by the iterator.
-
onBeforeChildNodes
protected void onBeforeChildNodes(P node)
Invoked before all the children of a node were memorized by the iterator.- Parameters:
node
- is the node for which all the child nodes will be memorized.
-
toTraversableChild
@Pure protected abstract P toTraversableChild(P parent, C child, int childIndex, int notNullChildIndex)
Replies an object to type N which is corresponding to the given child node retreived from the given parent node.- Parameters:
parent
- is the node from which the child node was retreived.child
- is the child node to test.childIndex
- is the position of thechild
node in itsparent
.childIndex
is always greater or equal tonotNullChildIndex
.notNullChildIndex
- is the position of thechild
node in the list of the not-null nodes of itsparent
.notNullChildIndex
is always lower or equal tochildIndex
.- Returns:
- the traversable node, or
null
if the node is not traversable.
-
hasNext
@Pure public boolean hasNext()
- Specified by:
hasNext
in interfaceIterator<P extends IterableNode<? extends C>>
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator<P extends IterableNode<? extends C>>
-
-