Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itk::VariableLengthVector< TValueType > Class Template Reference
[Data Representation Objects]

VariableLengthVector is intended to reperesent an array whose length can be defined at run-time. More...

#include <itkVariableLengthVector.h>

Collaboration diagram for itk::VariableLengthVector< TValueType >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TValueType ValueType
typedef TValueType ComponentType
typedef VariableLengthVector Self
typedef unsigned int ElementIdentifier

Public Member Functions

 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)
void Fill (TValueType const &v)
const Selfoperator= (const Self &v)
TValueType & operator[] (unsigned int i)
TValueType const & operator[] (unsigned int i) const
const TValueType & GetElement (unsigned int i) const
void SetElement (unsigned int i, const TValueType &value)
void SetData (TValueType *data, bool LetArrayManageMemory=false)
void SetData (TValueType *data, unsigned int sz, bool LetArrayManageMemory=false)
 ~VariableLengthVector ()
void Reserve (ElementIdentifier)
TValueType * AllocateElements (ElementIdentifier size) const
const TValueType * GetDataPointer ()
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
void SetSize (unsigned int sz, bool destroyExistingData=true)
unsigned int GetSize (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
Selfoperator-- ()
Selfoperator++ ()
Selfoperator-- (int)
Selfoperator++ (int)
template<class T> Selfoperator-= (const VariableLengthVector< T > &v)
Selfoperator-= (TValueType s)
template<class T> Selfoperator+= (const VariableLengthVector< T > &v)
Selfoperator+= (TValueType s)
template<class T> Selfoperator *= (T s)
template<class T> Selfoperator/= (T s)
Selfoperator- ()
bool operator== (const Self &v) const
bool operator!= (const Self &v) const

Detailed Description

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

VariableLengthVector is intended to reperesent an array whose length can be defined at run-time.

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

Note:
ITK itself provides several classes that can serve as Arrays. 1. FixedArray - Compile time fixed length arrays that's intended to represent an enumerated collection of n entities. 2. Array - Run time resizeable array that is intended to hold a collection of n entities 3. 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. 4. 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. 5. 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

Definition at line 67 of file itkVariableLengthVector.h.


Member Typedef Documentation

template<typename TValueType>
typedef TValueType itk::VariableLengthVector< TValueType >::ComponentType
 

Definition at line 73 of file itkVariableLengthVector.h.

template<typename TValueType>
typedef unsigned int itk::VariableLengthVector< TValueType >::ElementIdentifier
 

Typedef used to indicate the number of elements in the vector

Definition at line 77 of file itkVariableLengthVector.h.

Referenced by itk::VariableLengthVector< TValueType >::operator+(), itk::VariableLengthVector< TValueType >::operator-(), itk::VariableLengthVector< TValueType >::operator=(), and itk::VariableLengthVector< TValueType >::VariableLengthVector().

template<typename TValueType>
typedef VariableLengthVector itk::VariableLengthVector< TValueType >::Self
 

Definition at line 74 of file itkVariableLengthVector.h.

Referenced by itk::VariableLengthVector< TValueType >::operator+(), and itk::VariableLengthVector< TValueType >::operator-().

template<typename TValueType>
typedef TValueType itk::VariableLengthVector< TValueType >::ValueType
 

The element type stored at each location in the Array.

Definition at line 72 of file itkVariableLengthVector.h.


Constructor & Destructor Documentation

template<typename TValueType>
itk::VariableLengthVector< TValueType >::VariableLengthVector  ) 
 

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

template<typename TValueType>
itk::VariableLengthVector< TValueType >::VariableLengthVector unsigned int  dimension  ) 
 

Constructor with size. Size can only be changed by assignment

template<typename TValueType>
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.

template<typename TValueType>
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.

template<typename TValueType>
template<class T>
itk::VariableLengthVector< TValueType >::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 );

Definition at line 115 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValueType >::AllocateElements(), itk::VariableLengthVector< TValueType >::ElementIdentifier, and itk::VariableLengthVector< TValueType >::Size().

template<typename TValueType>
itk::VariableLengthVector< TValueType >::VariableLengthVector const VariableLengthVector< TValueType > &  v  ) 
 

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

template<typename TValueType>
itk::VariableLengthVector< TValueType >::~VariableLengthVector  ) 
 

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


Member Function Documentation

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

Allocate memory of certain size and return it.

Referenced by itk::VariableLengthVector< TValueType >::VariableLengthVector().

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

Set the all the elements of the array to the specified value

Referenced by itk::MeasurementVectorTraits::SetLength().

template<typename TValueType>
const TValueType* itk::VariableLengthVector< TValueType >::GetDataPointer  )  [inline]
 

Definition at line 227 of file itkVariableLengthVector.h.

template<typename TValueType>
const TValueType& itk::VariableLengthVector< TValueType >::GetElement unsigned int  i  )  const [inline]
 

Get one element

Definition at line 170 of file itkVariableLengthVector.h.

template<typename TValueType>
unsigned int itk::VariableLengthVector< TValueType >::GetNumberOfElements void   )  const [inline]
 

Return the number of elements in the Array

Definition at line 159 of file itkVariableLengthVector.h.

template<typename TValueType>
unsigned int itk::VariableLengthVector< TValueType >::GetSize void   )  const [inline]
 

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.

Definition at line 188 of file itkVariableLengthVector.h.

Referenced by itk::MeasurementVectorTraits::GetLength().

template<typename TValueType>
template<class T>
Self itk::VariableLengthVector< TValueType >::operator * s  )  const [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 265 of file itkVariableLengthVector.h.

template<typename TValueType>
template<class T>
Self& itk::VariableLengthVector< TValueType >::operator *= s  )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 367 of file itkVariableLengthVector.h.

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

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

template<typename TValueType>
Self itk::VariableLengthVector< TValueType >::operator+ TValueType  s  )  const [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 283 of file itkVariableLengthVector.h.

template<typename TValueType>
template<class T>
Self itk::VariableLengthVector< TValueType >::operator+ const VariableLengthVector< T > &  v  )  const [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 234 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValueType >::ElementIdentifier, and itk::VariableLengthVector< TValueType >::Self.

template<typename TValueType>
Self& itk::VariableLengthVector< TValueType >::operator++ int   )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 325 of file itkVariableLengthVector.h.

template<typename TValueType>
Self& itk::VariableLengthVector< TValueType >::operator++  )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 309 of file itkVariableLengthVector.h.

template<typename TValueType>
Self& itk::VariableLengthVector< TValueType >::operator+= TValueType  s  )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 359 of file itkVariableLengthVector.h.

template<typename TValueType>
template<class T>
Self& itk::VariableLengthVector< TValueType >::operator+= const VariableLengthVector< T > &  v  )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 351 of file itkVariableLengthVector.h.

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

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

template<typename TValueType>
Self itk::VariableLengthVector< TValueType >::operator- TValueType  s  )  const [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 292 of file itkVariableLengthVector.h.

template<typename TValueType>
template<class T>
Self itk::VariableLengthVector< TValueType >::operator- const VariableLengthVector< T > &  v  )  const [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 250 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValueType >::ElementIdentifier, and itk::VariableLengthVector< TValueType >::Self.

template<typename TValueType>
Self& itk::VariableLengthVector< TValueType >::operator-- int   )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 317 of file itkVariableLengthVector.h.

template<typename TValueType>
Self& itk::VariableLengthVector< TValueType >::operator--  )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 301 of file itkVariableLengthVector.h.

template<typename TValueType>
Self& itk::VariableLengthVector< TValueType >::operator-= TValueType  s  )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 342 of file itkVariableLengthVector.h.

template<typename TValueType>
template<class T>
Self& itk::VariableLengthVector< TValueType >::operator-= const VariableLengthVector< T > &  v  )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 334 of file itkVariableLengthVector.h.

template<typename TValueType>
template<class T>
Self itk::VariableLengthVector< TValueType >::operator/ s  )  const [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 274 of file itkVariableLengthVector.h.

template<typename TValueType>
template<class T>
Self& itk::VariableLengthVector< TValueType >::operator/= s  )  [inline]
 

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

Definition at line 375 of file itkVariableLengthVector.h.

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

Assignment operator *

template<typename TValueType>
template<class T>
const VariableLengthVector< TValueType >& itk::VariableLengthVector< TValueType >::operator= const VariableLengthVector< T > &  v  )  [inline]
 

Assignment operator *

Definition at line 137 of file itkVariableLengthVector.h.

References itk::VariableLengthVector< TValueType >::ElementIdentifier, and itk::VariableLengthVector< TValueType >::SetSize().

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

Mathematical operators.

Note:
For efficiency, the operators do not check to see of the length of the vectors are the same. For instance it is assumed that if you are adding VariableLengthVector a and b, they are of the same length.

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

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

Definition at line 167 of file itkVariableLengthVector.h.

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

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

Definition at line 164 of file itkVariableLengthVector.h.

template<typename TValueType>
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.

template<typename TValueType>
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 seperately 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 whereever 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.

template<typename TValueType>
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.

template<typename TValueType>
void itk::VariableLengthVector< TValueType >::SetElement unsigned int  i,
const TValueType &  value
[inline]
 

Set one element

Definition at line 174 of file itkVariableLengthVector.h.

template<typename TValueType>
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::MeasurementVectorTraits::SetLength().

template<typename TValueType>
unsigned int itk::VariableLengthVector< TValueType >::Size void   )  const [inline]
 

Return the number of elements in the Array

Definition at line 157 of file itkVariableLengthVector.h.

Referenced by itk::MeasurementVectorTraits::Assert(), and itk::VariableLengthVector< TValueType >::VariableLengthVector().


The documentation for this class was generated from the following file:
Generated at Thu May 25 02:32:47 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000