ITK
4.3.0
Insight Segmentation and Registration Toolkit
|
#include <itkVariableLengthVector.h>
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...
Arrays
. n
entities.n
entitiesn
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.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.Definition at line 76 of file itkVariableLengthVector.h.
Public Types | |
typedef TValueType | ComponentType |
typedef unsigned int | ElementIdentifier |
typedef NumericTraits < ValueType >::RealType | RealValueType |
typedef VariableLengthVector | Self |
typedef TValueType | ValueType |
Public Member Functions | |
TValueType * | AllocateElements (ElementIdentifier size) const |
void | DestroyExistingData () |
void | Fill (TValueType const &v) |
const TValueType * | GetDataPointer () const |
const TValueType & | GetElement (unsigned int i) const |
RealValueType | GetNorm () const |
unsigned int | GetSize (void) const |
RealValueType | GetSquaredNorm () const |
bool | operator!= (const Self &v) const |
Self & | operator- () |
const Self & | operator= (const Self &v) |
const Self & | operator= (TValueType const &v) |
bool | operator== (const Self &v) const |
TValueType & | operator[] (unsigned int i) |
TValueType const & | operator[] (unsigned int i) const |
void | Reserve (ElementIdentifier) |
void | SetData (TValueType *data, bool LetArrayManageMemory=false) |
void | SetData (TValueType *data, unsigned int sz, bool LetArrayManageMemory=false) |
void | SetElement (unsigned int i, const TValueType &value) |
void | SetSize (unsigned int sz, bool destroyExistingData=true) |
VariableLengthVector () | |
VariableLengthVector (unsigned int dimension) | |
VariableLengthVector (ValueType *data, unsigned int sz, bool LetArrayManageMemory=false) | |
VariableLengthVector (const ValueType *data, unsigned int sz, bool LetArrayManageMemory=false) | |
VariableLengthVector (const VariableLengthVector< TValueType > &v) | |
~VariableLengthVector () | |
template<class T > | |
VariableLengthVector (const VariableLengthVector< T > &v) | |
template<class T > | |
const VariableLengthVector < TValueType > & | operator= (const VariableLengthVector< T > &v) |
unsigned int | Size (void) const |
unsigned int | GetNumberOfElements (void) const |
template<class T > | |
Self | operator+ (const VariableLengthVector< T > &v) const |
template<class T > | |
Self | operator- (const VariableLengthVector< T > &v) const |
template<class T > | |
Self | operator* (T s) const |
template<class T > | |
Self | operator/ (T s) const |
Self | operator+ (TValueType s) const |
Self | operator- (TValueType s) const |
Self & | operator-- () |
Self & | operator++ () |
Self | operator-- (int) |
Self | operator++ (int) |
template<class T > | |
Self & | operator-= (const VariableLengthVector< T > &v) |
Self & | operator-= (TValueType s) |
template<class T > | |
Self & | operator+= (const VariableLengthVector< T > &v) |
Self & | operator+= (TValueType s) |
template<class T > | |
Self & | operator*= (T s) |
template<class T > | |
Self & | operator/= (T s) |
Private Attributes | |
TValueType * | m_Data |
bool | m_LetArrayManageMemory |
ElementIdentifier | m_NumElements |
typedef TValueType itk::VariableLengthVector< TValueType >::ComponentType |
Definition at line 82 of file itkVariableLengthVector.h.
typedef unsigned int itk::VariableLengthVector< TValueType >::ElementIdentifier |
Typedef used to indicate the number of elements in the vector
Definition at line 87 of file itkVariableLengthVector.h.
typedef NumericTraits< ValueType >::RealType itk::VariableLengthVector< TValueType >::RealValueType |
Definition at line 83 of file itkVariableLengthVector.h.
typedef VariableLengthVector itk::VariableLengthVector< TValueType >::Self |
Definition at line 84 of file itkVariableLengthVector.h.
typedef TValueType itk::VariableLengthVector< TValueType >::ValueType |
The element type stored at each location in the Array.
Definition at line 81 of file itkVariableLengthVector.h.
itk::VariableLengthVector< TValueType >::VariableLengthVector | ( | ) |
Default constructor. It is created with an empty array it has to be allocated later by assignment
|
explicit |
Constructor with size. Size can only be changed by assignment
itk::VariableLengthVector< TValueType >::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.
itk::VariableLengthVector< TValueType >::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.
|
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
Definition at line 124 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::AllocateElements(), itk::VariableLengthVector< TValueType >::m_Data, itk::VariableLengthVector< TValueType >::m_LetArrayManageMemory, itk::VariableLengthVector< TValueType >::m_NumElements, and itk::VariableLengthVector< TValueType >::Size().
itk::VariableLengthVector< TValueType >::VariableLengthVector | ( | const VariableLengthVector< TValueType > & | v | ) |
Copy constructer.. Override the default non-templated copy constructor that the compiler provides
itk::VariableLengthVector< TValueType >::~VariableLengthVector | ( | ) |
This destructor is not virtual for performance reasons. However, this means that subclasses cannot allocate memory.
TValueType* itk::VariableLengthVector< TValueType >::AllocateElements | ( | ElementIdentifier | size | ) | const |
Allocate memory of certain size and return it.
Referenced by itk::VariableLengthVector< TValueType >::VariableLengthVector().
void itk::VariableLengthVector< TValueType >::DestroyExistingData | ( | ) |
Destroy data that is allocated internally, if LetArrayManageMemory is true.
void itk::VariableLengthVector< TValueType >::Fill | ( | TValueType const & | v | ) |
Set the all the elements of the array to the specified value
Referenced by itk::MaskImageFilter< TInputImage, TMaskImage, TOutputImage >::CheckOutsideValue(), itk::NumericTraits< VariableLengthVector< T > >::max(), itk::NumericTraits< VariableLengthVector< T > >::min(), itk::NumericTraits< VariableLengthVector< T > >::NonpositiveMin(), itk::NumericTraits< VariableLengthVector< T > >::OneValue(), itk::NumericTraits< VariableLengthVector< T > >::SetLength(), and itk::NumericTraits< VariableLengthVector< T > >::ZeroValue().
|
inline |
Definition at line 235 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data.
Referenced by itk::VariableLengthVector< TValueType >::operator=(), and itk::MetaArrayWriter::SetInput().
|
inline |
Get one element
Definition at line 179 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data.
RealValueType itk::VariableLengthVector< TValueType >::GetNorm | ( | ) | const |
Returns vector's Euclidean Norm
Referenced by itk::DefaultConvertPixelTraits< VariableLengthVector< VComponent > >::GetScalarValue().
|
inline |
Return the number of elements in the Array
Definition at line 169 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Definition at line 200 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_NumElements.
Referenced by itk::MaskImageFilter< TInputImage, TMaskImage, TOutputImage >::CheckOutsideValue(), and itk::NumericTraits< VariableLengthVector< T > >::GetLength().
RealValueType itk::VariableLengthVector< TValueType >::GetSquaredNorm | ( | ) | const |
Returns vector's squared Euclidean Norm
bool itk::VariableLengthVector< TValueType >::operator!= | ( | const Self & | v | ) | const |
|
inline |
Multiply vector elements by a scalar 's'. The vector does not have to have the same element type as the scalar type. The scalar is cast to the output vector element type before the multiplication is performed.
Definition at line 295 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
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.
Definition at line 456 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Element-wise vector addition. The vectors do not have to have the same element type. The input vector elements are cast to the output vector element type before the addition is performed.
Definition at line 244 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::Size().
|
inline |
Add scalar 's' to each element of the vector.
Definition at line 325 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Prefix operator that adds 1 to each element of the vector.
Definition at line 361 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Postfix operator that adds 1 to each element of the vector.
Definition at line 383 of file itkVariableLengthVector.h.
|
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.
Definition at line 431 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Add scalar 's' to each element of the vector.
Definition at line 442 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Element-wise subtraction of vectors. The vectors do not have to have the same element type. The input vector elements are cast to the output vector element type before the subtraction is performed.
Definition at line 271 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::Size().
|
inline |
Subtract scalar 's' from each element of the vector.
Definition at line 337 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
Self& itk::VariableLengthVector< TValueType >::operator- | ( | ) |
Negates each vector element.
|
inline |
Prefix operator that subtracts 1 from each element of the vector.
Definition at line 350 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Postfix operator that subtracts 1 from each element of the vector.
Definition at line 373 of file itkVariableLengthVector.h.
|
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.
Definition at line 401 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Subtract scalar 's' from each element of the current vector.
Definition at line 412 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
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.
Definition at line 311 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
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.
Definition at line 471 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::m_NumElements.
|
inline |
Assignment operator
Definition at line 146 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::GetDataPointer(), itk::VariableLengthVector< TValueType >::m_Data, and itk::VariableLengthVector< TValueType >::SetSize().
const Self& itk::VariableLengthVector< TValueType >::operator= | ( | const Self & | v | ) |
Assignment operators
const Self& itk::VariableLengthVector< TValueType >::operator= | ( | TValueType const & | v | ) |
bool itk::VariableLengthVector< TValueType >::operator== | ( | const Self & | v | ) | const |
|
inline |
Return reference to the element at specified index. No range checking.
Definition at line 173 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data.
|
inline |
Return reference to the element at specified index. No range checking.
Definition at line 176 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data.
void itk::VariableLengthVector< TValueType >::Reserve | ( | ElementIdentifier | ) |
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.
void itk::VariableLengthVector< TValueType >::SetData | ( | TValueType * | 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.
Referenced by itk::MetaArrayReader::GetOutput().
void itk::VariableLengthVector< TValueType >::SetData | ( | TValueType * | 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.
|
inline |
Set one element
Definition at line 182 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_Data.
void itk::VariableLengthVector< TValueType >::SetSize | ( | unsigned int | sz, |
bool | destroyExistingData = true |
||
) |
Set the size to that given.
If destroyExistingData
is 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 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 true
.
Referenced by itk::VariableLengthVector< TValueType >::operator=(), and itk::NumericTraits< VariableLengthVector< T > >::SetLength().
|
inline |
Return the number of elements in the Array
Definition at line 168 of file itkVariableLengthVector.h.
References itk::VariableLengthVector< TValueType >::m_NumElements.
Referenced by itk::Statistics::MeasurementVectorTraits::Assert(), itk::DefaultConvertPixelTraits< VariableLengthVector< VComponent > >::GetNumberOfComponents(), itk::NumericTraits< VariableLengthVector< T > >::max(), itk::NumericTraits< VariableLengthVector< T > >::min(), itk::NumericTraits< VariableLengthVector< T > >::NonpositiveMin(), itk::NumericTraits< VariableLengthVector< T > >::OneValue(), itk::VariableLengthVector< TValueType >::operator+(), itk::VariableLengthVector< TValueType >::operator-(), itk::operator<<(), itk::MetaArrayWriter::SetInput(), itk::MeshIOBase::SetPixelType(), itk::VariableLengthVector< TValueType >::VariableLengthVector(), and itk::NumericTraits< VariableLengthVector< T > >::ZeroValue().
|
private |
Definition at line 500 of file itkVariableLengthVector.h.
Referenced by itk::VariableLengthVector< TValueType >::GetDataPointer(), itk::VariableLengthVector< TValueType >::GetElement(), itk::VariableLengthVector< TValueType >::operator*(), itk::VariableLengthVector< TValueType >::operator*=(), itk::VariableLengthVector< TValueType >::operator+(), itk::VariableLengthVector< TValueType >::operator++(), itk::VariableLengthVector< TValueType >::operator+=(), itk::VariableLengthVector< TValueType >::operator-(), itk::VariableLengthVector< TValueType >::operator--(), itk::VariableLengthVector< TValueType >::operator-=(), itk::VariableLengthVector< TValueType >::operator/(), itk::VariableLengthVector< TValueType >::operator/=(), itk::VariableLengthVector< TValueType >::operator=(), itk::VariableLengthVector< TValueType >::operator[](), itk::VariableLengthVector< TValueType >::SetElement(), and itk::VariableLengthVector< TValueType >::VariableLengthVector().
|
private |
Definition at line 498 of file itkVariableLengthVector.h.
Referenced by itk::VariableLengthVector< TValueType >::VariableLengthVector().
|
private |
Definition at line 501 of file itkVariableLengthVector.h.
Referenced by itk::VariableLengthVector< TValueType >::GetNumberOfElements(), itk::VariableLengthVector< TValueType >::GetSize(), itk::VariableLengthVector< TValueType >::operator*(), itk::VariableLengthVector< TValueType >::operator*=(), itk::VariableLengthVector< TValueType >::operator+(), itk::VariableLengthVector< TValueType >::operator++(), itk::VariableLengthVector< TValueType >::operator+=(), itk::VariableLengthVector< TValueType >::operator-(), itk::VariableLengthVector< TValueType >::operator--(), itk::VariableLengthVector< TValueType >::operator-=(), itk::VariableLengthVector< TValueType >::operator/(), itk::VariableLengthVector< TValueType >::operator/=(), itk::VariableLengthVector< TValueType >::Size(), and itk::VariableLengthVector< TValueType >::VariableLengthVector().