18 #ifndef __itkPreOrderTreeIterator_h
19 #define __itkPreOrderTreeIterator_h
26 template<
typename TTreeType >
27 class LeafTreeIterator;
29 template<
typename TTreeType >
68 template<
typename TTreeType >
74 template<
typename TTreeType >
82 template<
typename TTreeType >
86 if ( const_cast< TreeNodeType * >( FindNextNode() ) != ITK_NULLPTR )
95 template<
typename TTreeType >
99 this->m_Position =
const_cast< TreeNodeType *
>( FindNextNode() );
100 return this->m_Position->Get();
105 template<
typename TTreeType >
109 if ( this->m_Position == ITK_NULLPTR )
113 if ( this->m_Position->HasChildren() )
115 return dynamic_cast< const TreeNodeType *
>( this->m_Position->GetChild(0) );
119 if ( !this->m_Position->HasParent() )
128 if ( parent && parent->ChildPosition(this->m_Root) >= 0 )
133 int childPosition = parent->ChildPosition(child);
134 int lastChildPosition = parent->CountChildren() - 1;
136 while ( childPosition < lastChildPosition )
140 if ( help != ITK_NULLPTR )
147 while ( parent->HasParent() )
150 parent =
dynamic_cast< TreeNodeType *
>( parent->GetParent() );
153 if ( parent->ChildPosition(this->m_Root) >= 0 )
158 childPosition = parent->ChildPosition(child);
159 lastChildPosition = parent->CountChildren() - 1;
161 while ( childPosition < lastChildPosition )
165 if ( help != ITK_NULLPTR )
175 template<
typename TTreeType >
TTreeType::TreeNodeType TreeNodeType
TreeIteratorBase< TTreeType > * Clone()
PreOrderTreeIterator(const TTreeType *tree, const TreeNodeType *start=NULL)
Superclass::TreeNodeType TreeNodeType
const TreeNodeType * FindNextNode() const
TreeIteratorBase< TTreeType > Superclass
This class provides the base implementation for tree iterators.
TTreeType::ValueType ValueType
Superclass::NodeType NodeType