00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkArray_h
00018 #define __itkArray_h
00019
00020 #include "itkMacro.h"
00021 #include "vnl/vnl_vector.h"
00022
00023 namespace itk
00024 {
00025
00026
00043 template <typename TValueType >
00044 class Array : public vnl_vector< TValueType >
00045 {
00046 public:
00047
00049 typedef TValueType ValueType;
00050 typedef Array Self;
00051 typedef vnl_vector<TValueType> VnlVectorType;
00052
00053 public:
00054
00057 Array();
00058
00060 Array(unsigned int dimension);
00061
00063 void Fill (TValueType const& v) { fill(v); }
00064
00066 const Self & operator=( const Self &rhs );
00067 const Self & operator=( const VnlVectorType & rhs );
00068
00070 unsigned int Size (void ) const
00071 { return static_cast<unsigned int>( this->size() ); }
00072 unsigned int GetNumberOfElements(void) const
00073 { return static_cast<unsigned int>( this->size() ); }
00074
00076 const TValueType & GetElement( unsigned int i ) const
00077 { return this->operator[]( i ); }
00078
00080 void SetElement( unsigned int i, const TValueType & value )
00081 { this->operator[]( i ) = value; }
00082
00084 void SetSize(unsigned int sz);
00085 unsigned int GetSize(void) const
00086 { return static_cast<unsigned int>( this->size() ); }
00087
00093 void SetData(TValueType* data,bool LetArrayManageMemory = false);
00094
00097 ~Array();
00098
00099
00100
00101 private:
00102
00103 bool m_LetArrayManageMemory;
00104
00105 };
00106
00107
00108
00109 template <typename TValueType >
00110 std::ostream & operator<<(std::ostream &os, const Array<TValueType> &arr)
00111 {
00112 const unsigned int length = arr.size();
00113 const signed int last = (unsigned int) length - 1;
00114
00115 os << "[";
00116 for (signed int i=0; i < last; ++i)
00117 {
00118 os << arr[i] << ", ";
00119 }
00120 if (length >= 1)
00121 {
00122 os << arr[last];
00123 }
00124 os << "]";
00125 return os;
00126 }
00127
00128 }
00129
00130
00131
00132 #ifndef ITK_MANUAL_INSTANTIATION
00133 #include "itkArray.txx"
00134 #endif
00135
00136
00137 #endif