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

itkListSample.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkListSample.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/12/15 01:00:46 $ 00007 Version: $Revision: 1.20 $ 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 __itkListSample_h 00018 #define __itkListSample_h 00019 00020 #include "itkObjectFactory.h" 00021 #include "itkMacro.h" 00022 #include "itkListSampleBase.h" 00023 #include "itkFixedArray.h" 00024 #include "itkSmartPointer.h" 00025 00026 #include <vector> 00027 00028 namespace itk{ 00029 namespace Statistics{ 00030 00041 template< class TMeasurementVector > 00042 class ITK_EXPORT ListSample : public ListSampleBase< TMeasurementVector > 00043 { 00044 public: 00046 typedef ListSample Self; 00047 typedef ListSampleBase< TMeasurementVector > Superclass; 00048 typedef SmartPointer< Self > Pointer; 00049 typedef SmartPointer<const Self> ConstPointer; 00050 00052 itkTypeMacro(ListSample, ListSampleBase); 00053 00055 itkNewMacro(Self) ; 00056 00061 typedef typename Superclass::MeasurementVectorType MeasurementVectorType; 00062 typedef typename Superclass::MeasurementType MeasurementType; 00063 typedef typename Superclass::FrequencyType FrequencyType ; 00064 typedef typename Superclass::InstanceIdentifier InstanceIdentifier; 00065 typedef typename Superclass::SearchResultVectorType SearchResultVectorType ; 00066 00067 typedef MeasurementVectorType ValueType ; 00068 00070 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 00071 Superclass::MeasurementVectorSize); 00072 00074 typedef std::vector< MeasurementVectorType > InternalDataContainerType ; 00075 00080 void Resize( unsigned int n ) 00081 { m_InternalContainer.resize(n) ; } 00082 00084 void Clear() 00085 { m_InternalContainer.clear() ; } 00086 00088 void PushBack( MeasurementVectorType mv ) 00089 { m_InternalContainer.push_back( mv ) ; } 00090 00092 unsigned int Size() const 00093 { return static_cast<unsigned int>( m_InternalContainer.size() ); } 00094 00097 const MeasurementVectorType & GetMeasurementVector(const InstanceIdentifier &id) const; 00098 00101 void SetMeasurement(const InstanceIdentifier &id, 00102 const unsigned int &dim, 00103 const MeasurementType &value) ; 00104 00107 void SetMeasurementVector(const InstanceIdentifier &id, 00108 const MeasurementVectorType &mv) ; 00109 00111 FrequencyType GetFrequency(const InstanceIdentifier &id) const ; 00112 00114 FrequencyType GetTotalFrequency() const 00115 { return static_cast<FrequencyType>( m_InternalContainer.size() ); } 00116 00117 00118 00119 class Iterator 00120 { 00121 public: 00122 00123 Iterator(){} 00124 00125 Iterator(typename InternalDataContainerType::iterator iter, 00126 InstanceIdentifier iid) 00127 :m_Iter(iter), m_InstanceIdentifier(iid) 00128 {} 00129 00130 FrequencyType GetFrequency() const 00131 { return 1 ;} 00132 00133 const MeasurementVectorType & GetMeasurementVector() const 00134 { return (MeasurementVectorType&) *m_Iter ;} 00135 00136 InstanceIdentifier GetInstanceIdentifier() const 00137 { return m_InstanceIdentifier ;} 00138 00139 Iterator& operator++() 00140 { ++m_Iter ; ++m_InstanceIdentifier ; return *this ;} 00141 00142 Iterator& operator--() 00143 { 00144 --m_Iter ; 00145 00146 if ( m_InstanceIdentifier > 1 ) 00147 m_InstanceIdentifier; 00148 00149 return *this ; 00150 } 00151 00152 bool operator!=(const Iterator &it) 00153 { return (m_Iter != it.m_Iter) ;} 00154 00155 bool operator==(const Iterator &it) 00156 { return (m_Iter == it.m_Iter) ;} 00157 00158 Iterator& operator = (const Iterator iter) 00159 { 00160 m_Iter = iter.m_Iter; 00161 m_InstanceIdentifier = iter.m_InstanceIdentifier ; 00162 return *this ; 00163 } 00164 00165 Iterator(const Iterator &iter) 00166 { 00167 m_Iter = iter.m_Iter; 00168 m_InstanceIdentifier = iter.m_InstanceIdentifier ; 00169 } 00170 00171 private: 00172 typename InternalDataContainerType::iterator m_Iter ; 00173 InstanceIdentifier m_InstanceIdentifier ; 00174 } ; 00175 00176 00177 class ConstIterator 00178 { 00179 public: 00180 00181 ConstIterator(){} 00182 00183 ConstIterator(typename InternalDataContainerType::const_iterator iter, 00184 InstanceIdentifier iid) 00185 :m_Iter(iter), m_InstanceIdentifier(iid) 00186 {} 00187 00188 FrequencyType GetFrequency() const 00189 { return 1 ;} 00190 00191 const MeasurementVectorType & GetMeasurementVector() const 00192 { return (MeasurementVectorType&) *m_Iter ;} 00193 00194 InstanceIdentifier GetInstanceIdentifier() const 00195 { return m_InstanceIdentifier ;} 00196 00197 ConstIterator& operator++() 00198 { ++m_Iter ; ++m_InstanceIdentifier ; return *this ;} 00199 00200 ConstIterator& operator--() 00201 { 00202 --m_Iter ; 00203 00204 if ( m_InstanceIdentifier > 1 ) 00205 m_InstanceIdentifier; 00206 00207 return *this ; 00208 } 00209 00210 bool operator!=(const ConstIterator &it) 00211 { return (m_Iter != it.m_Iter) ;} 00212 00213 bool operator==(const ConstIterator &it) 00214 { return (m_Iter == it.m_Iter) ;} 00215 00216 ConstIterator& operator = (const ConstIterator iter) 00217 { 00218 m_Iter = iter.m_Iter; 00219 m_InstanceIdentifier = iter.m_InstanceIdentifier ; 00220 return *this ; 00221 } 00222 00223 ConstIterator(const ConstIterator &iter) 00224 { 00225 m_Iter = iter.m_Iter; 00226 m_InstanceIdentifier = iter.m_InstanceIdentifier ; 00227 } 00228 00229 private: 00230 typename InternalDataContainerType::const_iterator m_Iter ; 00231 InstanceIdentifier m_InstanceIdentifier ; 00232 } ; 00233 00235 Iterator Begin() 00236 { 00237 Iterator iter(m_InternalContainer.begin(), 0); 00238 return iter; 00239 } 00240 00242 Iterator End() 00243 { 00244 Iterator iter(m_InternalContainer.end(), m_InternalContainer.size()); 00245 return iter; 00246 } 00247 00249 ConstIterator Begin() const 00250 { 00251 ConstIterator iter(m_InternalContainer.begin(), 0); 00252 return iter; 00253 } 00254 00256 ConstIterator End() const 00257 { 00258 ConstIterator iter(m_InternalContainer.end(), m_InternalContainer.size()); 00259 return iter; 00260 } 00261 00262 protected: 00263 ListSample() ; 00264 virtual ~ListSample() {} 00265 void PrintSelf(std::ostream& os, Indent indent) const; 00266 00267 private: 00268 ListSample(const Self&) ; //purposely not implemented 00269 void operator=(const Self&) ; //purposely not implemented 00270 00271 InternalDataContainerType m_InternalContainer ; 00272 }; 00273 00274 } // end of namespace Statistics 00275 } // end of namespace itk 00276 00277 #ifndef ITK_MANUAL_INSTANTIATION 00278 #include "itkListSample.txx" 00279 #endif 00280 00281 #endif

Generated at Sun Apr 1 02:37:10 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000