18 #ifndef itkInOrderTreeIterator_h
19 #define itkInOrderTreeIterator_h
25 template<
typename TTreeType >
64 template<
typename TTreeType >
70 template<
typename TTreeType >
76 template<
typename TTreeType >
84 template<
typename TTreeType >
87 if ( const_cast< TreeNodeType * >( FindNextNode() ) !=
nullptr )
96 template<
typename TTreeType >
100 this->m_Position =
const_cast< TreeNodeType *
>( FindNextNode() );
101 return this->m_Position->Get();
106 template<
typename TTreeType >
110 if ( this->m_Position ==
nullptr )
115 if ( this->m_Position->HasChildren() )
117 return this->m_Position->GetChild(0);
120 if ( !this->m_Position->HasParent() )
128 int childPosition = parent->ChildPosition(child);
129 int lastChildPosition = parent->CountChildren() - 1;
131 while ( childPosition < lastChildPosition )
133 TreeNodeType *help = parent->GetChild(childPosition + 1);
134 if ( help !=
nullptr )
141 while ( parent->HasParent() )
144 parent = parent->GetParent();
147 if ( parent->ChildPosition(this->m_Root) >= 0 )
151 childPosition = parent->ChildPosition(child);
152 lastChildPosition = parent->CountChildren() - 1;
154 while ( childPosition < lastChildPosition )
156 TreeNodeType *help = parent->GetChild(childPosition + 1);
157 if ( help !=
nullptr )
167 template<
typename TTreeType >
typename Superclass::TreeNodeType TreeNodeType
typename TTreeType::ValueType ValueType
NodeType GetType() const override
const TreeNodeType * FindNextNode() const
InOrderTreeIterator(TreeType &start)
TreeIteratorBase< TTreeType > * Clone() override
This class provides the base implementation for tree iterators.
const ValueType & Next() override
typename TTreeType::TreeNodeType TreeNodeType
typename Superclass::NodeType NodeType
bool HasNext() const override