Class InfixDepthFirstTreeIterator<N extends TreeNode<?,N>>
- java.lang.Object
-
- org.arakhne.afc.math.tree.iterator.AbstractInfixDepthFirstTreeIterator<N,N>
-
- org.arakhne.afc.math.tree.iterator.InfixDepthFirstTreeIterator<N>
-
- Type Parameters:
N
- is the type of the tree nodes.
- All Implemented Interfaces:
Iterator<N>
,NodeSelectionTreeIterator<N>
public class InfixDepthFirstTreeIterator<N extends TreeNode<?,N>> extends AbstractInfixDepthFirstTreeIterator<N,N> implements NodeSelectionTreeIterator<N>
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 InfixDepthFirstTreeIterator(N node)
Constructor.InfixDepthFirstTreeIterator(N node, int infixPosition)
Constructor.InfixDepthFirstTreeIterator(N node, int infixPosition, NodeSelector<N> selector)
Constructor.InfixDepthFirstTreeIterator(N node, NodeSelector<N> selector)
Constructor.InfixDepthFirstTreeIterator(Tree<?,N> tree)
Constructor.InfixDepthFirstTreeIterator(Tree<?,N> tree, int infixPosition)
Constructor.InfixDepthFirstTreeIterator(Tree<?,N> tree, int infixPosition, NodeSelector<N> selector)
Constructor.InfixDepthFirstTreeIterator(Tree<?,N> tree, NodeSelector<N> selector)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
isTraversableParent(N parent)
Replies if an object to type N which is corresponding to the given child node retreived from the given parent node.void
setNodeSelector(NodeSelector<N> selector)
Set the node selector used by this iterator.protected N
toTraversableChild(N parent, N 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 org.arakhne.afc.math.tree.iterator.AbstractInfixDepthFirstTreeIterator
hasNext, next, remove
-
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, hasNext, next, remove
-
-
-
-
Constructor Detail
-
InfixDepthFirstTreeIterator
public InfixDepthFirstTreeIterator(Tree<?,N> tree)
Constructor.- Parameters:
tree
- is the tree to iterate.
-
InfixDepthFirstTreeIterator
public InfixDepthFirstTreeIterator(Tree<?,N> tree, NodeSelector<N> selector)
Constructor.- Parameters:
tree
- is the tree to iterate.selector
- permits to filter the nodes replied/traversed by this iterator.
-
InfixDepthFirstTreeIterator
public InfixDepthFirstTreeIterator(Tree<?,N> tree, int infixPosition)
Constructor.- Parameters:
tree
- is the tree to iterate.infixPosition
- is the index of the child which is assumed to be at the infixed position.
-
InfixDepthFirstTreeIterator
public InfixDepthFirstTreeIterator(Tree<?,N> tree, int infixPosition, NodeSelector<N> selector)
Constructor.- Parameters:
tree
- is the tree to iterate.infixPosition
- is the index of the child which is assumed to be at the infixed position.selector
- permits to filter the nodes replied/traversed by this iterator.
-
InfixDepthFirstTreeIterator
public InfixDepthFirstTreeIterator(N node)
Constructor.- Parameters:
node
- is the node to iterate.
-
InfixDepthFirstTreeIterator
public InfixDepthFirstTreeIterator(N node, NodeSelector<N> selector)
Constructor.- Parameters:
node
- is the node to iterate.selector
- permits to filter the nodes replied/traversed by this iterator.
-
InfixDepthFirstTreeIterator
public InfixDepthFirstTreeIterator(N 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.
-
InfixDepthFirstTreeIterator
public InfixDepthFirstTreeIterator(N node, int infixPosition, NodeSelector<N> selector)
Constructor.- Parameters:
node
- is the node to iterate.infixPosition
- is the index of the child which is assumed to be at the infixed position.selector
- permits to filter the nodes replied/traversed by this iterator.
-
-
Method Detail
-
setNodeSelector
public void setNodeSelector(NodeSelector<N> selector)
Description copied from interface:NodeSelectionTreeIterator
Set the node selector used by this iterator.- Specified by:
setNodeSelector
in interfaceNodeSelectionTreeIterator<N extends TreeNode<?,N>>
- Parameters:
selector
- permits to filter the nodes replied/tranversed by this iterator.
-
isTraversableParent
@Pure protected boolean isTraversableParent(N parent)
Description copied from class:AbstractInfixDepthFirstTreeIterator
Replies if an object to type N which is corresponding to the given child node retreived from the given parent node.- Specified by:
isTraversableParent
in classAbstractInfixDepthFirstTreeIterator<N extends TreeNode<?,N>,N extends TreeNode<?,N>>
- Parameters:
parent
- is the node from which the child node was retreived.- Returns:
true
if the given node is traversable,false
otherwise.
-
toTraversableChild
@Pure protected N toTraversableChild(N parent, N child)
Description copied from class:AbstractInfixDepthFirstTreeIterator
Replies an object to type N which is corresponding to the given child node retreived from the given parent node.- Specified by:
toTraversableChild
in classAbstractInfixDepthFirstTreeIterator<N extends TreeNode<?,N>,N extends TreeNode<?,N>>
- 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.
-
-