go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkVectorDataContainer.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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
22/*=========================================================================
23
24 Program: Insight Segmentation & Registration Toolkit
25 Module: $RCSfile$
26 Language: C++
27 Date: $Date: 2008-04-15 19:54:41 +0200 (Tue, 15 Apr 2008) $
28 Version: $Revision: 1573 $
29
30 Copyright (c) Insight Software Consortium. All rights reserved.
31 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
32
33 This software is distributed WITHOUT ANY WARRANTY; without even
34 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
35 PURPOSE. See the above copyright notices for more information.
36
37=========================================================================*/
38#ifndef __itkVectorDataContainer_h
39#define __itkVectorDataContainer_h
40
41#include "itkDataObject.h"
42#include "itkObjectFactory.h"
43
44#include <utility>
45#include <vector>
46
47namespace itk
48{
49
72template<
73typename TElementIdentifier,
74typename TElement
75>
77 public DataObject,
78 public std::vector< TElement >
79{
80public:
81
84 typedef DataObject Superclass;
86 typedef SmartPointer< const Self > ConstPointer;
87
89 typedef TElementIdentifier ElementIdentifier;
90 typedef TElement Element;
91
92private:
93
95 typedef std::vector< Element > VectorType;
96 typedef typename VectorType::size_type size_type;
97 typedef typename VectorType::iterator VectorIterator;
98 typedef typename VectorType::const_iterator VectorConstIterator;
99
100protected:
101
106 DataObject(), VectorType() {}
108 DataObject(), VectorType( n ) {}
110 DataObject(), VectorType( n, x ) {}
112 DataObject(), VectorType( r ) {}
113 template< typename InputIterator >
114 VectorDataContainer( InputIterator first, InputIterator last ) :
115 DataObject(), VectorType( first, last ) {}
116
117public:
118
121
123 itkNewMacro( Self );
124
126 itkTypeMacro( VectorDataContainer, DataObject );
127
129 class Iterator;
130 class ConstIterator;
131
134 {
135 return dynamic_cast< STLContainerType & >( *this );
136 }
137
138
141 {
142 return dynamic_cast< const STLContainerType & >( *this );
143 }
144
145
147 friend class Iterator;
148 friend class ConstIterator;
149
152 class Iterator
153 {
154public:
155
156 Iterator() {}
157 Iterator( size_type d, const VectorIterator & i ) : m_Pos( d ), m_Iter( i ) {}
158
159 Iterator & operator*() { return *this; }
160 Iterator * operator->() { return this; }
161 Iterator & operator++() { ++m_Pos; ++m_Iter; return *this; }
162 Iterator operator++( int ) { Iterator temp( *this ); ++m_Pos; ++m_Iter; return temp; }
163 Iterator operator+=( int j ){ m_Pos += j; m_Iter += j; return *this; }
164 Iterator operator-=( int j ){ m_Pos -= j; m_Iter -= j; return *this; }
165 Iterator & operator--() { --m_Pos; --m_Iter; return *this; }
166 Iterator operator--( int ) { Iterator temp( *this ); --m_Pos; --m_Iter; return temp; }
167
168 bool operator==( const Iterator & r ) const { return m_Iter == r.m_Iter; }
169 bool operator!=( const Iterator & r ) const { return m_Iter != r.m_Iter; }
170 bool operator==( const ConstIterator & r ) const { return m_Iter == r.m_Iter; }
171 bool operator!=( const ConstIterator & r ) const { return m_Iter != r.m_Iter; }
172
174 ElementIdentifier Index( void ) const { return static_cast< ElementIdentifier >( m_Pos ); }
175
177 Element & Value( void ) const { return *m_Iter; }
178
179private:
180
181 size_type m_Pos;
182 VectorIterator m_Iter;
183 friend class ConstIterator;
184 };
185
188 class ConstIterator
189 {
190public:
191
192 ConstIterator() {}
193 ConstIterator( size_type d, const VectorConstIterator & i ) : m_Pos( d ), m_Iter( i ) {}
194 ConstIterator( const Iterator & r ) { m_Pos = r.m_Pos; m_Iter = r.m_Iter; }
195
196 ConstIterator & operator*() { return *this; }
197 ConstIterator * operator->() { return this; }
198 ConstIterator & operator++() { ++m_Pos; ++m_Iter; return *this; }
199 ConstIterator operator++( int ) { ConstIterator temp( *this ); ++m_Pos; ++m_Iter; return temp; }
200 ConstIterator operator+=( int j ){ m_Pos += j; m_Iter += j; return *this; }
201 ConstIterator operator-=( int j ){ m_Pos -= j; m_Iter -= j; return *this; }
202 ConstIterator & operator--() { --m_Pos; --m_Iter; return *this; }
203 ConstIterator operator--( int ) { ConstIterator temp( *this ); --m_Pos; --m_Iter; return temp; }
204
205 ConstIterator & operator=( const Iterator & r ) { m_Pos = r.m_Pos; m_Iter = r.m_Iter; return *this; }
206
207 bool operator==( const Iterator & r ) const { return m_Iter == r.m_Iter; }
208 bool operator!=( const Iterator & r ) const { return m_Iter != r.m_Iter; }
209 bool operator==( const ConstIterator & r ) const { return m_Iter == r.m_Iter; }
210 bool operator!=( const ConstIterator & r ) const { return m_Iter != r.m_Iter; }
211
213 ElementIdentifier Index( void ) const { return static_cast< ElementIdentifier >( m_Pos ); }
214
216 const Element & Value( void ) const { return *m_Iter; }
217
218private:
219
220 size_type m_Pos;
221 VectorConstIterator m_Iter;
222 friend class Iterator;
223 };
224
225 /* Declare the public interface routines. */
226
236
244
254
260
266
273
279
286
293
300
304 ConstIterator Begin( void ) const;
305
309 ConstIterator End( void ) const;
310
315
319 Iterator End( void );
320
324 unsigned long Size( void ) const;
325
336
343 void Squeeze( void );
344
348 void Initialize( void ) override;
349
350};
351
352} // end namespace itk
353
354#ifndef ITK_MANUAL_INSTANTIATION
355#include "itkVectorDataContainer.hxx"
356#endif
357
358#endif // end __itkVectorDataContainer_h
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
SmartPointer< Self > Pointer
std::vector< Element > VectorType
VectorType::iterator VectorIterator
void InsertElement(ElementIdentifier, Element)
void CreateIndex(ElementIdentifier)
ConstIterator Begin(void) const
void DeleteIndex(ElementIdentifier)
TElementIdentifier ElementIdentifier
VectorType::const_iterator VectorConstIterator
VectorType::size_type size_type
Element GetElement(ElementIdentifier) const
VectorDataContainer(size_type n, const Element &x)
VectorDataContainer(InputIterator first, InputIterator last)
const Element & ElementAt(ElementIdentifier) const
ConstIterator End(void) const
void Initialize(void) override
Element & CreateElementAt(ElementIdentifier)
SmartPointer< const Self > ConstPointer
void Reserve(ElementIdentifier)
STLContainerType & CastToSTLContainer()
bool GetElementIfIndexExists(ElementIdentifier, Element *) const
bool IndexExists(ElementIdentifier) const
Element & ElementAt(ElementIdentifier)
void SetElement(ElementIdentifier, Element)
unsigned long Size(void) const
const STLContainerType & CastToSTLConstContainer() const
bool ITKOpenCL_EXPORT operator==(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)
bool ITKOpenCL_EXPORT operator!=(const OpenCLCommandQueue &lhs, const OpenCLCommandQueue &rhs)


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo