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: 2003/12/21 00:57:43 $
00007   Version:   $Revision: 1.33 $
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   
00051 public:
00052 
00055   Array(); 
00056 
00058   Array(unsigned int dimension);
00059 
00061   void Fill (TValueType const& v) { fill(v); }
00062  
00064   unsigned int Size (void ) const 
00065       { return static_cast<unsigned int>( this->size() ); }
00066   unsigned int GetNumberOfElements(void) const 
00067       { return static_cast<unsigned int>( this->size() ); }
00068 
00070   const TValueType & GetElement( unsigned int i ) const
00071     { return this->operator[]( i ); }
00072 
00074   void SetElement( unsigned int i, const TValueType & value )
00075     { this->operator[]( i ) = value; }
00076 
00078   void SetSize(unsigned int sz);
00079   unsigned int GetSize(void) const 
00080       { return static_cast<unsigned int>( this->size() ); }
00081 
00084   ~Array() {};
00085   
00086 };
00087 
00088 
00089   
00090 template <typename TValueType >
00091 std::ostream & operator<<(std::ostream &os, const Array<TValueType> &arr)
00092 {
00093   const unsigned int length = arr.size();
00094   const signed int last   = (unsigned int) length - 1;
00095 
00096   os << "[";
00097   for (signed int i=0; i < last; ++i)
00098     {
00099     os << arr[i] << ", ";
00100     }
00101   if (length >= 1)
00102     {
00103     os << arr[last];
00104     }
00105   os << "]";
00106   return os;
00107 }
00108 
00109 } // namespace itk
00110 
00111 
00112 
00113 #ifndef ITK_MANUAL_INSTANTIATION
00114 #include "itkArray.txx"
00115 #endif
00116 
00117 
00118 #endif

Generated at Sun Jan 25 13:19:28 2004 for ITK by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-2000