ITK
5.1.0
Insight Toolkit
ITK
Modules
Core
Common
include
itkLevelOrderTreeIterator.h
Go to the documentation of this file.
1
/*=========================================================================
2
*
3
* Copyright Insight Software Consortium
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0.txt
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*=========================================================================*/
18
#ifndef itkLevelOrderTreeIterator_h
19
#define itkLevelOrderTreeIterator_h
20
21
#include <queue>
22
#include <climits>
23
#include "
itkTreeIteratorBase.h
"
24
25
namespace
itk
26
{
33
template
<
typename
TTreeType>
34
class
ITK_TEMPLATE_EXPORT
LevelOrderTreeIterator
:
public
TreeIteratorBase
<TTreeType>
35
{
36
public
:
37
39
using
Self
=
LevelOrderTreeIterator
;
40
using
Superclass
=
TreeIteratorBase<TTreeType>
;
41
using
TreeType
= TTreeType;
42
using
ValueType
=
typename
TTreeType::ValueType;
43
using
TreeNodeType
=
typename
Superclass::TreeNodeType
;
44
using
NodeType
=
typename
Superclass::NodeType
;
45
47
LevelOrderTreeIterator
(
TreeType
* tree,
int
endLevel = INT_MAX,
const
TreeNodeType
* start =
nullptr
);
48
50
LevelOrderTreeIterator
(
TreeType
* tree,
int
startLevel,
int
endLevel,
const
TreeNodeType
* start =
nullptr
);
51
52
~
LevelOrderTreeIterator
()
override
=
default
;
53
55
NodeType
56
GetType()
const override
;
57
59
int
60
GetStartLevel()
const
;
61
63
int
64
GetEndLevel()
const
;
65
67
int
68
GetLevel()
const
;
69
71
TreeIteratorBase<TTreeType>
*
72
Clone()
override
;
73
75
const
Self
&
76
operator=
(
const
Self
& iterator)
77
{
78
if
(
this
!= &iterator)
79
{
80
this->Superclass::operator=(iterator);
81
m_StartLevel = iterator.
m_StartLevel
;
82
m_EndLevel = iterator.
m_EndLevel
;
83
m_Queue = iterator.
m_Queue
;
84
}
85
return
*
this
;
86
}
88
89
protected
:
91
const
ValueType &
92
Next()
override
;
93
95
bool
96
HasNext()
const override
;
97
98
private
:
99
const
TreeNodeType *
100
FindNextNode()
const
;
101
102
const
TreeNodeType *
103
FindNextNodeHelp()
const
;
104
105
int
106
GetLevel(
const
TreeNodeType * node)
const
;
107
108
int
m_StartLevel
;
109
int
m_EndLevel
;
110
mutable
std::queue<const TreeNodeType *>
m_Queue
;
111
};
112
113
}
// end namespace itk
114
115
#ifndef ITK_MANUAL_INSTANTIATION
116
# include "itkLevelOrderTreeIterator.hxx"
117
#endif
118
119
#endif
itkTreeIteratorBase.h
itk::LevelOrderTreeIterator::TreeNodeType
typename Superclass::TreeNodeType TreeNodeType
Definition:
itkLevelOrderTreeIterator.h:43
itk::TreeIteratorBase
This class provides the base implementation for tree iterators.
Definition:
itkTreeIteratorBase.h:58
itk::LevelOrderTreeIterator::ValueType
typename TTreeType::ValueType ValueType
Definition:
itkLevelOrderTreeIterator.h:42
itk::LevelOrderTreeIterator::operator=
const Self & operator=(const Self &iterator)
Definition:
itkLevelOrderTreeIterator.h:76
itk::LevelOrderTreeIterator
Iterate over a tree in level order.
Definition:
itkLevelOrderTreeIterator.h:34
itk::TreeIteratorBaseNodeEnum
TreeIteratorBaseNodeEnum
Definition:
itkTreeIteratorBase.h:29
itk::LevelOrderTreeIterator::m_EndLevel
int m_EndLevel
Definition:
itkLevelOrderTreeIterator.h:109
itk::TreeIteratorBase::TreeNodeType
typename TTreeType::TreeNodeType TreeNodeType
Definition:
itkTreeIteratorBase.h:64
itk::LevelOrderTreeIterator::m_Queue
std::queue< const TreeNodeType * > m_Queue
Definition:
itkLevelOrderTreeIterator.h:110
itk::LevelOrderTreeIterator::NodeType
typename Superclass::NodeType NodeType
Definition:
itkLevelOrderTreeIterator.h:44
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition:
itkArray.h:26
itk::LevelOrderTreeIterator::m_StartLevel
int m_StartLevel
Definition:
itkLevelOrderTreeIterator.h:108
itk::LevelOrderTreeIterator::TreeType
TTreeType TreeType
Definition:
itkLevelOrderTreeIterator.h:41
Generated on Wed Dec 25 2019 01:52:54 for ITK by
1.8.16