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

itkArray.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkArray.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/08/12 13:56:34 $
00007   Version:   $Revision: 1.44 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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 
00068   Array( ValueType* data, unsigned int sz, bool LetArrayManageMemory = false);
00069   
00076   Array( const ValueType* data, unsigned int sz, bool LetArrayManageMemory = false);
00077 
00078 
00080   void Fill (TValueType const& v) { fill(v); }
00081 
00083   const Self & operator=( const Self &rhs );
00084   const Self & operator=( const VnlVectorType & rhs );
00085  
00087   unsigned int Size (void ) const 
00088       { return static_cast<unsigned int>( this->size() ); }
00089   unsigned int GetNumberOfElements(void) const 
00090       { return static_cast<unsigned int>( this->size() ); }
00091 
00093   const TValueType & GetElement( unsigned int i ) const
00094     { return this->operator[]( i ); }
00095 
00097   void SetElement( unsigned int i, const TValueType & value )
00098     { this->operator[]( i ) = value; }
00099 
00101   void SetSize(unsigned int sz);
00102   unsigned int GetSize(void) const 
00103       { return static_cast<unsigned int>( this->size() ); }
00104 
00110   void SetData(TValueType* data,bool LetArrayManageMemory = false);
00111 
00121   void SetData(TValueType* data, unsigned int sz, bool LetArrayManageMemory = false);
00122 
00123   
00126   ~Array();
00127 
00128 
00129 
00130 private:
00131 
00132   bool m_LetArrayManageMemory;
00133   
00134 };
00135 
00136 
00137   
00138 template <typename TValueType >
00139 std::ostream & operator<<(std::ostream &os, const Array<TValueType> &arr)
00140 {
00141   const unsigned int length = arr.size();
00142   const signed int last   = (unsigned int) length - 1;
00143 
00144   os << "[";
00145   for (signed int i=0; i < last; ++i)
00146     {
00147     os << arr[i] << ", ";
00148     }
00149   if (length >= 1)
00150     {
00151     os << arr[last];
00152     }
00153   os << "]";
00154   return os;
00155 }
00156 
00157 } // namespace itk
00158 
00159 
00160 
00161 #ifndef ITK_MANUAL_INSTANTIATION
00162 #include "itkArray.txx"
00163 #endif
00164 
00165 
00166 #endif

Generated at Wed May 24 22:47:09 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000