ITK  6.0.0
Insight Toolkit
Public Types | Public Member Functions | Private Attributes | List of all members
itk::Array< TValue > Class Template Reference

#include <itkArray.h>

Detailed Description

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

Array class with size defined at construction time.

This class derives from the vnl_vector<> class. Its size is assigned at construction time (run time) and can not be changed afterwards except by using assignment to another Array.

The class is templated over the type of the elements.

Template parameters for class Array:

Definition at line 47 of file itkArray.h.

+ Inheritance diagram for itk::Array< TValue >:
+ Collaboration diagram for itk::Array< TValue >:

Public Types

using Self = Array
 
using SizeValueType = typename vnl_vector< TValue >::size_type
 
using ValueType = TValue
 
using VnlVectorType = vnl_vector< TValue >
 

Public Member Functions

 Array ()=default
 
 Array (const Array &)
 
 Array (const ValueType *datain, SizeValueType sz)
 
 Array (const VnlVectorType &)
 
 Array (SizeValueType dimension)
 
 Array (SizeValueType dimension, const ValueType &value)
 
 Array (ValueType *datain, SizeValueType sz, bool LetArrayManageMemory=false)
 
void Fill (TValue const &v)
 
const TValue & GetElement (SizeValueType i) const
 
SizeValueType GetSize () const
 
Selfoperator= (const Self &rhs)
 
Selfoperator= (const VnlVectorType &rhs)
 
void SetData (TValue *datain, SizeValueType sz, bool LetArrayManageMemory=false)
 
void SetDataSameSize (TValue *datain, bool LetArrayManageMemory=false)
 
void SetElement (SizeValueType i, const TValue &value)
 
void SetSize (SizeValueType sz)
 
void Swap (Array &other) noexcept
 
 ~Array () override
 
template<typename TArrayValue >
 Array (const Array< TArrayValue > &r)
 
SizeValueType Size () const
 
unsigned int GetNumberOfElements () const
 

Private Attributes

bool m_LetArrayManageMemory { true }
 

Member Typedef Documentation

◆ Self

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

Definition at line 53 of file itkArray.h.

◆ SizeValueType

template<typename TValue>
using itk::Array< TValue >::SizeValueType = typename vnl_vector<TValue>::size_type

Definition at line 55 of file itkArray.h.

◆ ValueType

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

The element type stored at each location in the Array.

Definition at line 52 of file itkArray.h.

◆ VnlVectorType

template<typename TValue>
using itk::Array< TValue >::VnlVectorType = vnl_vector<TValue>

Definition at line 54 of file itkArray.h.

Constructor & Destructor Documentation

◆ Array() [1/8]

template<typename TValue>
itk::Array< TValue >::Array ( )
default

Default constructor. It is created with an empty array it has to be allocated later by assignment

◆ Array() [2/8]

template<typename TValue>
itk::Array< TValue >::Array ( const Array< TValue > &  )

Copy constructor. Uses VNL copy constructor with correct setting for memory management.

◆ Array() [3/8]

template<typename TValue>
itk::Array< TValue >::Array ( const VnlVectorType )
explicit

Construct from a VnlVectorType

◆ Array() [4/8]

template<typename TValue>
itk::Array< TValue >::Array ( SizeValueType  dimension)
explicit

Constructor with size. Size can only be changed by assignment.

Note
This constructor may not initialize its elements.

◆ Array() [5/8]

template<typename TValue>
itk::Array< TValue >::Array ( SizeValueType  dimension,
const ValueType value 
)
explicit

Constructor with size and initial value for each element.

◆ Array() [6/8]

template<typename TValue>
itk::Array< TValue >::Array ( ValueType datain,
SizeValueType  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.

◆ Array() [7/8]

template<typename TValue>
itk::Array< TValue >::Array ( const ValueType datain,
SizeValueType  sz 
)

Constructor that initializes array with contents from a user supplied const buffer. The pointer to the buffer and the length is specified. By default, the array does a deep copy of the const pointer data, so the array class also manages memory.

◆ Array() [8/8]

template<typename TValue>
template<typename TArrayValue >
itk::Array< TValue >::Array ( const Array< TArrayValue > &  r)
inline

Constructor to initialize an array from another of any data type

Definition at line 102 of file itkArray.h.

◆ ~Array()

template<typename TValue>
itk::Array< TValue >::~Array ( )
override

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

Member Function Documentation

◆ Fill()

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

◆ GetElement()

template<typename TValue>
const TValue& itk::Array< TValue >::GetElement ( SizeValueType  i) const
inline

Get one element

Definition at line 141 of file itkArray.h.

◆ GetNumberOfElements()

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

Return the number of elements in the Array

Definition at line 133 of file itkArray.h.

◆ GetSize()

template<typename TValue>
SizeValueType itk::Array< TValue >::GetSize ( ) const
inline

◆ operator=() [1/2]

template<typename TValue>
Self& itk::Array< TValue >::operator= ( const Self rhs)

Copy operator

◆ operator=() [2/2]

template<typename TValue>
Self& itk::Array< TValue >::operator= ( const VnlVectorType rhs)

◆ SetData()

template<typename TValue>
void itk::Array< TValue >::SetData ( TValue *  datain,
SizeValueType  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.

Referenced by itk::MetaArrayReader::GetOutput(), and itk::OptimizerParametersHelper< TValue >::MoveDataPointer().

◆ SetDataSameSize()

template<typename TValue>
void itk::Array< TValue >::SetDataSameSize ( TValue *  datain,
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. NOTE: This signature requires that internal array is being replaced by data array of exactly the same size

◆ SetElement()

template<typename TValue>
void itk::Array< TValue >::SetElement ( SizeValueType  i,
const TValue &  value 
)
inline

Set one element

Definition at line 148 of file itkArray.h.

◆ SetSize()

template<typename TValue>
void itk::Array< TValue >::SetSize ( SizeValueType  sz)

◆ Size()

template<typename TValue>
SizeValueType itk::Array< TValue >::Size ( ) const
inline

◆ Swap()

template<typename TValue>
void itk::Array< TValue >::Swap ( Array< TValue > &  other)
inlinenoexcept

Definition at line 202 of file itkArray.h.

Member Data Documentation

◆ m_LetArrayManageMemory

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

Indicates whether this array manages the memory of its data.

Definition at line 211 of file itkArray.h.


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