ITK  5.1.0
Insight Segmentation and Registration Toolkit
Classes | Related Functions | List of all members
itk::VariableLengthVector< TValue > Class Template Reference

#include <itkConstantBoundaryCondition.h>

Classes

struct  AllocateRootPolicy
 
struct  AlwaysReallocate
 
struct  DontShrinkToFit
 
struct  DumpOldValues
 
struct  KeepOldValues
 
struct  KeepValuesRootPolicy
 
struct  NeverReallocate
 
struct  ShrinkToFit
 

Related Functions

(Note that these are not member functions.)

template<typename TExpr1 , typename TExpr2 >
mpl::EnableIf< Details::op::CanBeMultiplied< TExpr1, TExpr2 >, VariableLengthVectorExpression< TExpr1, TExpr2, Details::op::Mult > >::Type operator* (TExpr1 const &lhs, TExpr2 const &rhs)
 
template<typename TExpr1 , typename TExpr2 >
mpl::EnableIf< Details::op::CanBeAddedOrSubtracted< TExpr1, TExpr2 >, VariableLengthVectorExpression< TExpr1, TExpr2, Details::op::Plus > >::Type operator+ (TExpr1 const &lhs, TExpr2 const &rhs)
 
template<typename TExpr1 , typename TExpr2 >
mpl::EnableIf< Details::op::CanBeAddedOrSubtracted< TExpr1, TExpr2 >, VariableLengthVectorExpression< TExpr1, TExpr2, Details::op::Sub > >::Type operator- (TExpr1 const &lhs, TExpr2 const &rhs)
 
template<typename TExpr1 , typename TExpr2 >
mpl::EnableIf< Details::op::CanBeDivided< TExpr1, TExpr2 >, VariableLengthVectorExpression< TExpr1, TExpr2, Details::op::Div > >::Type operator/ (TExpr1 const &lhs, TExpr2 const &rhs)
 
Serialization
template<typename TValue >
std::ostream & operator<< (std::ostream &os, const VariableLengthVector< TValue > &arr)
 
Standard compliance functions
template<typename T >
void swap (VariableLengthVector< T > &l_, VariableLengthVector< T > &r_) noexcept
 

Policies

The following Policies will be used by itk::VariableLengthVector::SetSize

using ValueType = TValue
 
using ComponentType = TValue
 
using RealValueType = typename NumericTraits< ValueType >::RealType
 
using Self = VariableLengthVector
 
using ElementIdentifier = unsigned int
 
bool m_LetArrayManageMemory { true }
 
TValue * m_Data
 
ElementIdentifier m_NumElements { 0 }
 
 VariableLengthVector ()
 
 VariableLengthVector (unsigned int dimension)
 
 VariableLengthVector (ValueType *data, unsigned int sz, bool LetArrayManageMemory=false)
 
 VariableLengthVector (const ValueType *data, unsigned int sz, bool LetArrayManageMemory=false)
 
template<typename T >
 VariableLengthVector (const VariableLengthVector< T > &v)
 
 VariableLengthVector (const VariableLengthVector< TValue > &v)
 
void Swap (Self &v) noexcept
 
 VariableLengthVector (Self &&v) noexcept
 
Selfoperator= (Self &&v) noexcept
 
template<typename TExpr1 , typename TExpr2 , typename TBinaryOp >
 VariableLengthVector (VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &rhs)
 
template<typename TExpr1 , typename TExpr2 , typename TBinaryOp >
Selfoperator= (VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &rhs)
 
void Fill (TValue const &v)
 
template<typename T >
Selfoperator= (const VariableLengthVector< T > &v)
 
Selfoperator= (const Self &v)
 
SelfFastAssign (const Self &v)
 
Selfoperator= (TValue const &v)
 
unsigned int Size () const
 
unsigned int GetSize () const
 
unsigned int GetNumberOfElements () const
 
TValue & operator[] (unsigned int i)
 
const TValue & operator[] (unsigned int i) const
 
const TValue & GetElement (unsigned int i) const
 
void SetElement (unsigned int i, const TValue &value)
 
template<typename TReallocatePolicy , typename TKeepValuesPolicy >
void SetSize (unsigned int sz, TReallocatePolicy reallocatePolicy, TKeepValuesPolicy keepValues)
 
void SetSize (unsigned int sz, bool destroyExistingData=true)
 
void DestroyExistingData ()
 
void SetData (TValue *data, bool LetArrayManageMemory=false)
 
void SetData (TValue *data, unsigned int sz, bool LetArrayManageMemory=false)
 
 ~VariableLengthVector ()
 
void Reserve (ElementIdentifier size)
 
TValue * AllocateElements (ElementIdentifier size) const
 
const TValue * GetDataPointer () const
 
Selfoperator-- ()
 
Selfoperator++ ()
 
Self operator-- (int)
 
Self operator++ (int)
 
template<typename T >
Selfoperator-= (const VariableLengthVector< T > &v)
 
Selfoperator-= (TValue s)
 
template<typename T >
Selfoperator+= (const VariableLengthVector< T > &v)
 
Selfoperator+= (TValue s)
 
template<typename TExpr1 , typename TExpr2 , typename TBinaryOp >
Selfoperator+= (VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &rhs)
 
template<typename TExpr1 , typename TExpr2 , typename TBinaryOp >
Selfoperator-= (VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &rhs)
 
template<typename T >
Selfoperator*= (T s)
 
Selfoperator*= (TValue s)
 
template<typename T >
Selfoperator/= (T s)
 
Selfoperator- ()
 
bool operator== (const Self &v) const
 
bool operator!= (const Self &v) const
 
RealValueType GetNorm () const
 
RealValueType GetSquaredNorm () const
 
bool IsAProxy () const
 

Detailed Description

template<typename TValue>
class itk::VariableLengthVector< TValue >

Represents an array whose length can be defined at run-time.

This class is templated over the data type. This data-type is meant to be a scalar, such as float, double etc...

Note
ITK itself provides several classes that can serve as Arrays.
  • FixedArray - Compile time fixed length arrays that's intended to represent an enumerated collection of n entities.
  • Array - Run time resizeable array that is intended to hold a collection of n entities
  • Vector - Compile time fixed length array that is intended to hold a collection of n data types. A vector usually has a mathematical meaning. It should only be used when mathematical operations such as addition, multiplication by a scalar, product etc make sense.
  • VariableLengthVector - Run time array that is intended to hold a collection of scalar data types. Again, it should be used only when mathematical operations on it are relevant. If not, use an Array.
  • Point - Represents the spatial coordinates of a spatial location. Operators on Point reflect geometrical concepts.
For the reasons listed above, you cannot instantiate
VariableLengthVector< bool >
.
Design Considerations: We do not derive from vnl_vector to avoid being limited by the explicit template instantiations of vnl_vector and other hacks that vnl folks have been forced to use.
Note
This work is part of the National Alliance for Medical Image Computing (NAMIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149.
See also
CovariantVector
SymmetricSecondRankTensor
RGBPixel
DiffusionTensor3D
ITK Sphinx Examples:
\li All ITK Sphinx Examples
Invariant
If m_LetArrayManageMemory is true, m_Data is deletable (whether it's null or pointing to something with no elements. i.e. m_NumElements may be 0 and yet m_Data may be not null.)
Examples
SphinxExamples/src/Core/Common/CreateVectorImage/Code.cxx, SphinxExamples/src/Core/Common/CustomOperationToEachPixelInImage/Code.cxx, SphinxExamples/src/Core/Common/VariableLengthVector/Code.cxx, SphinxExamples/src/Core/ImageAdaptors/ViewComponentVectorImageAsScaleImage/Code.cxx, and SphinxExamples/src/Filtering/ImageIntensity/ExtractComponentOfVectorImage/Code.cxx.

Definition at line 28 of file itkConstantBoundaryCondition.h.

Member Typedef Documentation

◆ ComponentType

template<typename TValue>
using itk::VariableLengthVector< TValue >::ComponentType = TValue

The element type stored at each location in the Array.

Definition at line 321 of file itkVariableLengthVector.h.

◆ ElementIdentifier

template<typename TValue>
using itk::VariableLengthVector< TValue >::ElementIdentifier = unsigned int

Typedef used to indicate the number of elements in the vector

Definition at line 326 of file itkVariableLengthVector.h.

◆ RealValueType

template<typename TValue>
using itk::VariableLengthVector< TValue >::RealValueType = typename NumericTraits<ValueType>::RealType

The element type stored at each location in the Array.

Definition at line 322 of file itkVariableLengthVector.h.

◆ Self

template<typename TValue>
using itk::VariableLengthVector< TValue >::Self = VariableLengthVector

The element type stored at each location in the Array.

Definition at line 323 of file itkVariableLengthVector.h.

◆ ValueType

template<typename TValue>
using itk::VariableLengthVector< TValue >::ValueType = TValue

The element type stored at each location in the Array.

Definition at line 320 of file itkVariableLengthVector.h.

Constructor & Destructor Documentation

◆ VariableLengthVector() [1/8]

template<typename TValue>
itk::VariableLengthVector< TValue >::VariableLengthVector ( )

Default constructor. It is created with an empty array it has to be allocated later by assignment, SetSize() or Reserve().

Postcondition
m_Data is null
m_NumElements is 0
m_LetArrayManageMemory is true

◆ VariableLengthVector() [2/8]

template<typename TValue>
itk::VariableLengthVector< TValue >::VariableLengthVector ( unsigned int  dimension)
explicit

Constructor with size. Size can only be changed by assignment, SetSize() or Reserve().

Postcondition
m_Data is not null and points to an array of m_NumElements, even if m_NumElements is 0
values are left uninitialized.
m_NumElements is dimension
m_LetArrayManageMemory is true

◆ VariableLengthVector() [3/8]

template<typename TValue>
itk::VariableLengthVector< TValue >::VariableLengthVector ( ValueType data,
unsigned int  sz,
bool  LetArrayManageMemory = false 
)

Constructor that initializes array with contents from a user supplied buffer. The pointer to the buffer and the length is specified. By default, the array does not manage the memory of the buffer. It merely points to that location and it is the user's responsibility to delete it. If LetArrayManageMemory is true, then this class will free the memory when this object is destroyed.

Postcondition
m_Data == data
values are left unmodified
m_NumElements == sz
m_LetArrayManageMemory == LetArrayManageMemory

◆ VariableLengthVector() [4/8]

template<typename TValue>
itk::VariableLengthVector< TValue >::VariableLengthVector ( const ValueType data,
unsigned int  sz,
bool  LetArrayManageMemory = false 
)

Constructor that initializes array with contents from a user supplied buffer. The pointer to the buffer and the length is specified. By default, the array does not manage the memory of the buffer. It merely points to that location and it is the user's responsibility to delete it. If LetArrayManageMemory is true, then this class will free the memory when this object is destroyed.

Warning
This overload receives a non-modiable array, and yet it will let the end-user try to modify it through VariableLengthVector interface. Use this constructor with care as this may lead to undefined behaviour. Prefer using VariableLengthVector<const TValue> instead of VariableLengthVector<TValue> in case we which to use this constructor.
Postcondition
m_Data == data
values are left unmodified
m_NumElements == sz
m_LetArrayManageMemory == LetArrayManageMemory

◆ VariableLengthVector() [5/8]

template<typename TValue>
template<typename T >
itk::VariableLengthVector< TValue >::VariableLengthVector ( const VariableLengthVector< T > &  v)
inline

Copy constructor. The reason why the copy constructor and the assignment operator are templated is that it will allow implicit casts to be performed. For instance:

VariableLengthVector< int > vI;
VariableLengthVector< float > vF( vI );
or for instance vF = static_cast< VariableLengthVector< float > >( vI );
Note
However that static casting in this way will imply the allocation of a temporary VariableLengthVector. Prefer to directly use the assignment converting operator in code where uses of static_cast<> would be required.
Postcondition
m_Data is not null and points to an array of m_NumElements, if m_NumElements is 0, otherwise it's null.
values are left uninitialized.
m_NumElements is v.GetSize()
m_LetArrayManageMemory is true

Definition at line 402 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValue >::Size().

◆ VariableLengthVector() [6/8]

template<typename TValue>
itk::VariableLengthVector< TValue >::VariableLengthVector ( const VariableLengthVector< TValue > &  v)

Copy constructor. Overrides the default non-templated copy constructor that the compiler provides.

Postcondition
m_Data is not null and points to an array of m_NumElements, if m_NumElements is 0, otherwise it's null.
values are left uninitialized.
m_NumElements is v.GetSize()
m_LetArrayManageMemory is true

◆ VariableLengthVector() [7/8]

template<typename TValue>
itk::VariableLengthVector< TValue >::VariableLengthVector ( Self &&  v)
noexcept

C++11 Move Constructor.

Postcondition
v is destructible and assignable.
m_NumElements == 0
m_LetArrayManageMemory == true
m_Data == nullptr
Built object contains old v data.

◆ VariableLengthVector() [8/8]

template<typename TValue>
template<typename TExpr1 , typename TExpr2 , typename TBinaryOp >
itk::VariableLengthVector< TValue >::VariableLengthVector ( VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &  rhs)

Constructor from an Expression Template vector.

Template Parameters
TExpr1Type of the left sub-expression
TExpr2Type of the right sub-expression
TBinaryOpBinary Operation to apply to both sub-expressions.
Parameters
[in]rhsNon evaluated Expression Template.

Builds the new VariableLengthVector with an expression template. The code loops over all components from the template expression, and evaluates them on the fly to fill the content of the new vector.

Postcondition
m_Data is not null and points to an array of m_NumElements, even if m_NumElements is 0
*this == rhs
m_NumElements is rhs.GetSize()
m_LetArrayManageMemory is true

◆ ~VariableLengthVector()

template<typename TValue>
itk::VariableLengthVector< TValue >::~VariableLengthVector ( )

This destructor is not virtual for performance reasons. However, this means that subclasses cannot allocate memory.

Member Function Documentation

◆ AllocateElements()

template<typename TValue>
TValue* itk::VariableLengthVector< TValue >::AllocateElements ( ElementIdentifier  size) const

Allocate memory of certain size and return it.

Returns
a non-null pointer to an array of size elements (0 is a valid parameter).

◆ DestroyExistingData()

template<typename TValue>
void itk::VariableLengthVector< TValue >::DestroyExistingData ( )

Destroy data that is allocated internally, if LetArrayManageMemory is true.

◆ FastAssign()

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::FastAssign ( const Self v)

Fast Assignment.

Precondition
m_LetArrayManageMemory is true: the VariableLengthVector is not a proxy, checked with an assertion. Call SetSize(GetSize(), NeverReallocate(), DumpOldValues()) to ensure a vector is not a proxy anymore.
current size is identical to the one from the right hand side operand, checked with an assertion.
Doesn't not support empty vectors.

◆ Fill()

template<typename TValue>
void itk::VariableLengthVector< TValue >::Fill ( TValue const &  v)

◆ GetDataPointer()

template<typename TValue>
const TValue* itk::VariableLengthVector< TValue >::GetDataPointer ( ) const
inline

The element type stored at each location in the Array.

Definition at line 767 of file itkVariableLengthVector.h.

Referenced by itk::MetaArrayWriter::SetInput().

◆ GetElement()

template<typename TValue>
const TValue& itk::VariableLengthVector< TValue >::GetElement ( unsigned int  i) const
inline

Get one element

Definition at line 616 of file itkVariableLengthVector.h.

◆ GetNorm()

template<typename TValue>
RealValueType itk::VariableLengthVector< TValue >::GetNorm ( ) const

◆ GetNumberOfElements()

template<typename TValue>
unsigned int itk::VariableLengthVector< TValue >::GetNumberOfElements ( ) const
inline

The element type stored at each location in the Array.

Definition at line 602 of file itkVariableLengthVector.h.

◆ GetSize()

template<typename TValue>
unsigned int itk::VariableLengthVector< TValue >::GetSize ( ) const
inline

◆ GetSquaredNorm()

template<typename TValue>
RealValueType itk::VariableLengthVector< TValue >::GetSquaredNorm ( ) const

Returns vector's squared Euclidean Norm

◆ IsAProxy()

template<typename TValue>
bool itk::VariableLengthVector< TValue >::IsAProxy ( ) const
inline

letArrayManageMemory getter.

Definition at line 1004 of file itkVariableLengthVector.h.

◆ operator!=()

template<typename TValue>
bool itk::VariableLengthVector< TValue >::operator!= ( const Self v) const

The element type stored at each location in the Array.

◆ operator*=() [1/2]

template<typename TValue>
template<typename T >
Self& itk::VariableLengthVector< TValue >::operator*= ( s)
inline

Multiply each element of the vector by a scalar 's'. The scalar value is cast to the current vector element type prior to multiplication.

Exceptions
None

Definition at line 937 of file itkVariableLengthVector.h.

◆ operator*=() [2/2]

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator*= ( TValue  s)
inline

Multiply each element of the vector by a scalar 's'.

Exceptions
None

Definition at line 952 of file itkVariableLengthVector.h.

◆ operator++() [1/2]

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator++ ( )
inline

Prefix operator that adds 1 to each element of the vector.

Definition at line 787 of file itkVariableLengthVector.h.

◆ operator++() [2/2]

template<typename TValue>
Self itk::VariableLengthVector< TValue >::operator++ ( int  )
inline

Postfix operator that adds 1 to each element of the vector.

Definition at line 811 of file itkVariableLengthVector.h.

◆ operator+=() [1/3]

template<typename TValue>
template<typename T >
Self& itk::VariableLengthVector< TValue >::operator+= ( const VariableLengthVector< T > &  v)
inline

Element-wise addition of vector 'v' to the current vector. The vectors do not have to have the same element type. The input vector elements are cast to the current vector element type before the addition is performed.

Exceptions
None
Note
For efficiency, the length of the vectors is not checked; they are assumed to have the same length.

Definition at line 863 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValue >::GetSize().

◆ operator+=() [2/3]

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator+= ( TValue  s)
inline

Add scalar 's' to each element of the vector.

Definition at line 876 of file itkVariableLengthVector.h.

◆ operator+=() [3/3]

template<typename TValue>
template<typename TExpr1 , typename TExpr2 , typename TBinaryOp >
Self& itk::VariableLengthVector< TValue >::operator+= ( VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &  rhs)
inline

Compound addition operator with a expression template vector.

Template Parameters
TExpr1Type of the left sub-expression
TExpr2Type of the right sub-expression
TBinaryOpBinary Operation to apply to both sub-expressions.
Parameters
[in]rhsNon evaluated Expression Template.
Precondition
Size() == rhs.Size(), checked with an assertion
Note
The elements of the expression template are evaluated one by one.

Definition at line 897 of file itkVariableLengthVector.h.

◆ operator-()

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator- ( )

Negates each vector element.

Warning
This operator has a non standard semantics. Instead of returning a new VariableLengthVector, it modifies the current object.

◆ operator--() [1/2]

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator-- ( )
inline

Prefix operator that subtracts 1 from each element of the vector.

Definition at line 775 of file itkVariableLengthVector.h.

◆ operator--() [2/2]

template<typename TValue>
Self itk::VariableLengthVector< TValue >::operator-- ( int  )
inline

Postfix operator that subtracts 1 from each element of the vector.

Definition at line 800 of file itkVariableLengthVector.h.

◆ operator-=() [1/3]

template<typename TValue>
template<typename T >
Self& itk::VariableLengthVector< TValue >::operator-= ( const VariableLengthVector< T > &  v)
inline

Element-wise subtraction of vector 'v' from the current vector. The vectors do not have to have the same element type. The input vector elements are cast to the current vector element type before the subtraction is performed.

Exceptions
None
Note
For efficiency, the length of the vectors is not checked; they are assumed to have the same length.

Definition at line 830 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValue >::GetSize().

◆ operator-=() [2/3]

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator-= ( TValue  s)
inline

Subtract scalar 's' from each element of the current vector.

Definition at line 843 of file itkVariableLengthVector.h.

◆ operator-=() [3/3]

template<typename TValue>
template<typename TExpr1 , typename TExpr2 , typename TBinaryOp >
Self& itk::VariableLengthVector< TValue >::operator-= ( VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &  rhs)
inline

Compound subtraction operator with a expression template vector.

Template Parameters
TExpr1Type of the left sub-expression
TExpr2Type of the right sub-expression
TBinaryOpBinary Operation to apply to both sub-expressions.
Parameters
[in]rhsNon evaluated Expression Template.
Precondition
Size() == rhs.Size(), checked with an assertion
Note
The elements of the expression template are evaluated one by one.

Definition at line 919 of file itkVariableLengthVector.h.

◆ operator/=()

template<typename TValue>
template<typename T >
Self& itk::VariableLengthVector< TValue >::operator/= ( s)
inline

Divide vector elements by a scalar 's'. The vector does not have to have the same element type as the scalar type. Both the scalar and vector elements are cast to the RealValueType prior to division, and the result is cast to the ValueType.

Exceptions
None

Definition at line 970 of file itkVariableLengthVector.h.

◆ operator=() [1/5]

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator= ( const Self v)

Copy-Assignment operator.

Note
Ensures a String Exception Guarantee: resists to self-assignment, and no changes are made if memory cannot be allocated to hold the new elements. This is expecting TValue assignment is a noexcept operation.
Postcondition
if called on a VariableLengthVector proxy, the referenced values are left unchanged.
m_Data is not null and points to an array of m_NumElements, if m_NumElements is not 0. m_Data may be null otherwise (an empty vector is assigned into another empty vector)
m_LetArrayManageMemory is true
GetSize() == v.GetSize()
*this == v

◆ operator=() [2/5]

template<typename TValue>
template<typename T >
Self& itk::VariableLengthVector< TValue >::operator= ( const VariableLengthVector< T > &  v)
inline

Converting assignment operator.

Note
Ensures a String Exception Guarantee: resists to self-assignment, and no changes are made if memory cannot be allocated to hold the new elements. This presumes TValue assignment is a noexcept operation.
Postcondition
if called on a VariableLengthVector proxy, the referenced values are left unchanged.
m_LetArrayManageMemory is true
GetSize() == v.GetSize(), modulo precision
*this == v

Definition at line 532 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValue >::Size().

◆ operator=() [3/5]

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator= ( Self &&  v)
noexcept

C++11 Move assignement operator.

Precondition
v shall not be the same as the current object
Postcondition
v is destructible and assignable.
m_NumElements == 0
m_LetArrayManageMemory == true
m_Data == nullptr
Current object contains old v data.

◆ operator=() [4/5]

template<typename TValue>
Self& itk::VariableLengthVector< TValue >::operator= ( TValue const &  v)

Assignment operator from a numeric value.

Precondition
This assumes m_LetArrayManageMemory is true, but it is unchecked. If this operator is called on a VariableLengthVector proxy, referenced values will be overwritten.
Postcondition
Elements in [m_Data, m_Data+GetSize()) will be equal to v, modulo precision

◆ operator=() [5/5]

template<typename TValue>
template<typename TExpr1 , typename TExpr2 , typename TBinaryOp >
Self& itk::VariableLengthVector< TValue >::operator= ( VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &  rhs)

Assignment from an Expression Template vector.

Template Parameters
TExpr1Type of the left sub-expression
TExpr2Type of the right sub-expression
TBinaryOpBinary Operation to apply to both sub-expressions.
Parameters
[in]rhsNon evaluated Expression Template.

Resets the new VariableLengthVector with an expression template. The code loops over all components from the template expression, and evaluates them on the fly to fill the content of the current vector.

Postcondition
if called on a VariableLengthVector proxy, the referenced values are left unchanged.
m_Data is not null and points to an array of m_NumElements, if m_NumElements is not 0. m_Data may be null otherwise (an empty vector is assigned into another empty vector)
m_LetArrayManageMemory is true
GetSize() == rhs.GetSize()
*this == rhs

◆ operator==()

template<typename TValue>
bool itk::VariableLengthVector< TValue >::operator== ( const Self v) const

The element type stored at each location in the Array.

◆ operator[]() [1/2]

template<typename TValue>
TValue& itk::VariableLengthVector< TValue >::operator[] ( unsigned int  i)
inline

Return reference to the element at specified index. No range checking.

Definition at line 609 of file itkVariableLengthVector.h.

◆ operator[]() [2/2]

template<typename TValue>
const TValue& itk::VariableLengthVector< TValue >::operator[] ( unsigned int  i) const
inline

Return reference to the element at specified index. No range checking.

Definition at line 612 of file itkVariableLengthVector.h.

◆ Reserve()

template<typename TValue>
void itk::VariableLengthVector< TValue >::Reserve ( ElementIdentifier  size)

Reserves memory of a certain length.

If the array already contains data, the existing data is copied over and
new space is allocated, if necessary. If the length to reserve is less
than the current number of elements, then an appropriate number of elements
are discarded.
\post \c m_Data is not null and can hold \c size elements.
\post \c m_LetArrayManageMemory may be left unchanged if there already are
enough elements.

\note You may prefer instead
`SetSize(N, DontShrinkToFit(), KeepOldValues());` that ensures that the
array is not a proxy at the end of the operation.

◆ SetData() [1/2]

template<typename TValue>
void itk::VariableLengthVector< TValue >::SetData ( TValue *  data,
bool  LetArrayManageMemory = false 
)

Set the pointer from which the data is imported. If "LetArrayManageMemory" is false, then the application retains the responsibility of freeing the memory for this data. If "LetArrayManageMemory" is true, then this class will free the memory when this object is destroyed.

Warning
The size of the new data shall match vector current size. Prefer the other overload.
Postcondition
old m_Data is deleted iff m_LetArrayManageMemory is true
m_Data == data
m_LetArrayManageMemory ==LetArrayManageMemory
Size() is left unmodified.

Referenced by itk::MetaArrayReader::GetOutput().

◆ SetData() [2/2]

template<typename TValue>
void itk::VariableLengthVector< TValue >::SetData ( TValue *  data,
unsigned int  sz,
bool  LetArrayManageMemory = false 
)

Similar to the previous method. In the above method, the size must be separately set prior to using user-supplied data. This introduces an unnecessary allocation step to be performed. This method avoids it and should be used to import data wherever possible to avoid this. Set the pointer from which the data is imported. If "LetArrayManageMemory" is false, then the application retains the responsibility of freeing the memory for this data. If "LetArrayManageMemory" is true, then this class will free the memory when this object is destroyed.

Postcondition
old m_Data is deleted iff m_LetArrayManageMemory is true
m_Data == data
m_LetArrayManageMemory ==LetArrayManageMemory
m_NumElements == sz

◆ SetElement()

template<typename TValue>
void itk::VariableLengthVector< TValue >::SetElement ( unsigned int  i,
const TValue &  value 
)
inline

Set one element

Definition at line 623 of file itkVariableLengthVector.h.

◆ SetSize() [1/2]

template<typename TValue>
void itk::VariableLengthVector< TValue >::SetSize ( unsigned int  sz,
bool  destroyExistingData = true 
)
inline

Set the size to that given.

If \c destroyExistingData is \c false:
If the array already contains data, the existing data is copied over and
new space is allocated, if necessary. If the length to reserve is less
than the current number of elements, then an appropriate number of elements
are discarded.
   If \c true, the size is set destructively to the length given. If the
length is different from the current length, existing data will be lost.
The default is \c true. 

Definition at line 676 of file itkVariableLengthVector.h.

◆ SetSize() [2/2]

template<typename TValue>
template<typename TReallocatePolicy , typename TKeepValuesPolicy >
void itk::VariableLengthVector< TValue >::SetSize ( unsigned int  sz,
TReallocatePolicy  reallocatePolicy,
TKeepValuesPolicy  keepValues 
)

◆ Size()

template<typename TValue>
unsigned int itk::VariableLengthVector< TValue >::Size ( ) const
inline

◆ Swap()

template<typename TValue>
void itk::VariableLengthVector< TValue >::Swap ( Self v)
inlinenoexcept

Swaps two VariableLengthVector 's.

Precondition
Expects either none of the VariableLengthVector to act as a proxy, or both, checked with an assertion.
Postcondition
*this and old contents are swapped.
Parameters
[in,out]vother VariableLengthVector to be swapped with.
Exceptions
None
See also
itk::swap()

Definition at line 441 of file itkVariableLengthVector.h.

References itk::swap().

Friends And Related Function Documentation

◆ operator*()

template<typename TExpr1 , typename TExpr2 >
mpl::EnableIf< Details::op::CanBeMultiplied< TExpr1, TExpr2 >, VariableLengthVectorExpression< TExpr1, TExpr2, Details::op::Mult > >::Type operator* ( TExpr1 const &  lhs,
TExpr2 const &  rhs 
)
related

Multiplication between a VariableLengthVector and a scalar. This operation is generic and takes one array and one number (on either side).

Returns
an expression template proxy object.
Exceptions
NoneAs no allocation will be performed.
See also
mpl::IsArray<> to know the exact array types recognized as array by this traits

Definition at line 1333 of file itkVariableLengthVector.h.

◆ operator+()

template<typename TExpr1 , typename TExpr2 >
mpl::EnableIf< Details::op::CanBeAddedOrSubtracted< TExpr1, TExpr2 >, VariableLengthVectorExpression< TExpr1, TExpr2, Details::op::Plus > >::Type operator+ ( TExpr1 const &  lhs,
TExpr2 const &  rhs 
)
related

Addition involving a VariableLengthVector. This operation is generic and takes:

  • two arrays,
  • or one array and one number (on either side)
    Returns
    an expression template proxy object.
    Exceptions
    NoneAs no allocation will be performed.
    See also
    mpl::IsArray<> to know the exact array types recognized as array by this traits

Definition at line 1300 of file itkVariableLengthVector.h.

◆ operator-()

template<typename TExpr1 , typename TExpr2 >
mpl::EnableIf< Details::op::CanBeAddedOrSubtracted< TExpr1, TExpr2 >, VariableLengthVectorExpression< TExpr1, TExpr2, Details::op::Sub > >::Type operator- ( TExpr1 const &  lhs,
TExpr2 const &  rhs 
)
related

Subtraction involving a VariableLengthVector. This operation is generic and takes:

  • two arrays,
  • or one array and one number (on either side)
    Returns
    an expression template proxy object.
    Exceptions
    NoneAs no allocation will be performed.
    See also
    mpl::IsArray<> to know the exact array types recognized as array by this traits

Definition at line 1317 of file itkVariableLengthVector.h.

◆ operator/()

template<typename TExpr1 , typename TExpr2 >
mpl::EnableIf< Details::op::CanBeDivided< TExpr1, TExpr2 >, VariableLengthVectorExpression< TExpr1, TExpr2, Details::op::Div > >::Type operator/ ( TExpr1 const &  lhs,
TExpr2 const &  rhs 
)
related

Division of a VariableLengthVector by a scalar. This operation is generic and takes one array and one number.

Returns
an expression template proxy object.
Exceptions
NoneAs no allocation will be performed.
See also
mpl::IsArray<> to know the exact array types recognized as array by this traits

Definition at line 1348 of file itkVariableLengthVector.h.

◆ operator<<()

template<typename TValue >
std::ostream & operator<< ( std::ostream &  os,
const VariableLengthVector< TValue > &  arr 
)
related

Serialization of VariableLengthVector

Definition at line 1413 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValue >::Size().

◆ swap()

template<typename T >
void swap ( VariableLengthVector< T > &  l_,
VariableLengthVector< T > &  r_ 
)
related

swap() overload for VariableLengthVector

Exceptions
None

Definition at line 1455 of file itkVariableLengthVector.h.

Member Data Documentation

◆ m_Data

template<typename TValue>
TValue* itk::VariableLengthVector< TValue >::m_Data
private

The element type stored at each location in the Array.

Definition at line 1012 of file itkVariableLengthVector.h.

◆ m_LetArrayManageMemory

template<typename TValue>
bool itk::VariableLengthVector< TValue >::m_LetArrayManageMemory { true }
private

The element type stored at each location in the Array.

Definition at line 1010 of file itkVariableLengthVector.h.

◆ m_NumElements

template<typename TValue>
ElementIdentifier itk::VariableLengthVector< TValue >::m_NumElements { 0 }
private

The element type stored at each location in the Array.

Definition at line 1013 of file itkVariableLengthVector.h.


The documentation for this class was generated from the following files: