Class AbstractInfixDepthFirstTreeIterator<P extends IterableNode<? extends C>,C extends IterableNode<?>>
- java.lang.Object
-
- org.arakhne.afc.math.tree.iterator.AbstractInfixDepthFirstTreeIterator<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:
InfixDepthFirstTreeIterator
public abstract class AbstractInfixDepthFirstTreeIterator<P extends IterableNode<? extends C>,C extends IterableNode<?>> extends Object implements Iterator<P>
This class is an infixed depth-first iterator on a tree.This iterator has an infix position which describes when to treat the parent node inside the set of child treatments. Significant values of this position are:
0
the parent is treated before the child at index 0
. This is equivalent to a prefixed depth-first iterator. We recommend to usePrefixDepthFirstTreeIterator
insteed of this iterator class.between 1
andgetChildCount()-1
the parent is treated before the child at the specified index. getChildCount()
the parent is treated after the last child. This is equivalent to a postfixed depth-first iterator. We recommend to use PostfixDepthFirstTreeIterator
insteed of this iterator class.By default this iterator assumes an infix index that corresponds to the middle of each child set (ie,
getChildCount()/2
).- 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 AbstractInfixDepthFirstTreeIterator(P node)
Constructor.AbstractInfixDepthFirstTreeIterator(P node, int infixPosition)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
protected abstract boolean
isTraversableParent(P parent)
Replies if an object to type N which is corresponding to the given child node retreived from the given parent node.P
next()
void
remove()
protected abstract P
toTraversableChild(P parent, C child)
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
-
AbstractInfixDepthFirstTreeIterator
public AbstractInfixDepthFirstTreeIterator(P node)
Constructor.- Parameters:
node
- is the node to iterate.
-
AbstractInfixDepthFirstTreeIterator
public AbstractInfixDepthFirstTreeIterator(P node, int infixPosition)
Constructor.- Parameters:
node
- is the node to iterate.infixPosition
- is the index of the child which is assumed to be at the infixed position.
-
-
Method Detail
-
toTraversableChild
@Pure protected abstract P toTraversableChild(P parent, C child)
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.- Returns:
- the traversable node, or
null
if the node is not traversable.
-
isTraversableParent
@Pure protected abstract boolean isTraversableParent(P parent)
Replies if 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.- Returns:
true
if the given node is traversable,false
otherwise.
-
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>>
-
-