ITK  5.1.0
Insight Toolkit
itkTreeContainer.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 itkTreeContainer_h
19 #define itkTreeContainer_h
20 
21 #include "itkTreeContainerBase.h"
23 
24 namespace itk
25 {
37 template <typename TValue>
38 class ITK_TEMPLATE_EXPORT TreeContainer : public TreeContainerBase<TValue>
39 {
40 public:
46  using ValueType = TValue;
48 
52 
54  itkNewMacro(Self);
55 
57  itkTypeMacro(TreeContainer, TreeContainerBase);
58 
60  TreeContainer(int defaultChildrenCount);
61 
64 
66  bool
67  SetRoot(const TValue element) override;
68 
70  bool
71  SetRoot(IteratorType & pos);
72 
74  bool
75  SetRoot(TreeNode<TValue> * node) override;
76 
78  bool
79  Contains(const TValue element) override;
80 
82  int
83  Count() const override;
84 
86  bool
87  IsLeaf(const TValue element) override;
88 
90  bool
91  IsRoot(const TValue element) override;
92 
94  bool
95  Clear() override;
96 
98  bool
100 
102  bool
103  Swap(IteratorType & v, IteratorType & w);
104 
106  const TreeNodeType *
107  GetRoot() const override
108  {
109  return m_Root.GetPointer();
110  }
111 
113  bool
114  Add(const TValue child, const TValue parent);
115 
117  const TreeNodeType *
118  GetNode(TValue val) const;
119 
120 protected:
121  TreeContainer();
122  ~TreeContainer() override = default;
123 
125 
127 
128  void
129  PrintSelf(std::ostream & os, Indent indent) const override;
130 };
131 } // namespace itk
132 
133 #ifndef ITK_MANUAL_INSTANTIATION
134 # include "itkTreeContainer.hxx"
135 #endif
136 
137 #endif
itk::TreeNode
Represents a node in a tree.
Definition: itkTreeNode.h:43
itkPreOrderTreeIterator.h
itk::TreeContainer::ValueType
TValue ValueType
Definition: itkTreeContainer.h:46
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::TreeIteratorBase
This class provides the base implementation for tree iterators.
Definition: itkTreeIteratorBase.h:58
itkTreeContainerBase.h
itk::TreeContainer::m_Root
TreeNodeType::Pointer m_Root
Definition: itkTreeContainer.h:124
itk::PreOrderTreeIterator
Definition: itkPreOrderTreeIterator.h:30
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::TreeContainer::m_DefaultChildrenCount
int m_DefaultChildrenCount
Definition: itkTreeContainer.h:126
itk::TreeContainerBase
A base class for tree containers.
Definition: itkTreeContainerBase.h:34
itk::TreeContainer::GetRoot
const TreeNodeType * GetRoot() const override
Definition: itkTreeContainer.h:107
itk::operator==
bool operator==(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:532
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::TreeContainer
A tree container.
Definition: itkTreeContainer.h:38