Iterate on a Vector Container#
Synopsis#
basic operation on VectorContainer
Results#
Output:
[1, 2]
[2, 3]
Code#
C++#
#include "itkVectorContainer.h"
#include "itkPoint.h"
int
main()
{
constexpr unsigned int Dimension = 2;
using CoordType = double;
using PointType = itk::Point<CoordType, Dimension>;
using VectorContainerType = itk::VectorContainer<int, PointType>;
PointType p0;
p0[0] = 1.0;
p0[1] = 2.0;
PointType p1;
p1[0] = 2.0;
p1[1] = 3.0;
auto points = VectorContainerType::New();
points->Reserve(2);
VectorContainerType::Iterator point = points->Begin();
point->Value() = p0;
++point;
point->Value() = p1;
point = points->Begin();
while (point != points->End())
{
std::cout << point->Value() << std::endl;
++point;
}
return EXIT_SUCCESS;
}
Classes demonstrated#
-
template<typename TElementIdentifier, typename TElement>
class VectorContainer : public itk::Object, private std::vector<TElement> Define a front-end to the STL “vector” container that conforms to the IndexedContainerInterface.
This is a full-fleged Object, so there is modification time, debug, and reference count information.
- ITK Sphinx Examples:
- Template Parameters
TElementIdentifier
: An INTEGRAL type for use in indexing the vector.TElement
: The element type stored in the container.