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: 2004/06/03 02:14:07 $
00007   Version:   $Revision: 1.42 $
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 
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 } // namespace itk
00129 
00130 
00131 
00132 #ifndef ITK_MANUAL_INSTANTIATION
00133 #include "itkArray.txx"
00134 #endif
00135 
00136 
00137 #endif

Generated at Tue Mar 29 23:46:30 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000