Orfeo Toolbox  3.16
itkFixedArray.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkFixedArray.txx,v $
5  Language: C++
6  Date: $Date: 2009-11-28 09:15:37 $
7  Version: $Revision: 1.25 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkFixedArray_txx
18 #define __itkFixedArray_txx
19 
20 #include "itkFixedArray.h"
22 
23 namespace itk
24 {
25 
30 template <typename TValueType, unsigned int VLength>
33 {
34 }
35 
39 template <typename TValueType, unsigned int VLength>
42 {
43  for(Iterator i = Begin(); i != End(); ++i)
44  {
45  *i = r;
46  }
47 }
48 
54 template <typename TValueType, unsigned int VLength>
56 ::FixedArray(const ValueType r[VLength])
57 {
58  ConstIterator input = r;
59  Iterator i = this->Begin();
60  while( i != this->End() )
61  {
62  *i++ = *input++;
63  }
64 }
65 
66 
72 template <typename TValueType, unsigned int VLength>
75 ::operator= (const ValueType r[VLength])
76 {
77  if(r == m_InternalArray) return *this;
78  ConstIterator input = r;
79  Iterator i = this->Begin();
80  while( i != this->End() )
81  {
82  *i++ = *input++;
83  }
84  return *this;
85 }
86 
87 
91 template <typename TValueType, unsigned int VLength>
92 bool
94 ::operator== (const FixedArray& r) const
95 {
96  ConstIterator i = this->Begin();
97  ConstIterator j = r.Begin();
98 
99  while( i != this->End() )
100  {
101  if ( *i != *j )
102  {
103  return false;
104  }
105  ++j;
106  ++i;
107  }
108 
109  return true;
110 }
111 
115 template <typename TValueType, unsigned int VLength>
119 {
120  return Iterator(m_InternalArray);
121 }
122 
123 
127 template <typename TValueType, unsigned int VLength>
130 ::Begin() const
131 {
132  return ConstIterator(m_InternalArray);
133 }
134 
135 
139 template <typename TValueType, unsigned int VLength>
143 {
144  return Iterator(m_InternalArray+VLength);
145 }
146 
147 
151 template <typename TValueType, unsigned int VLength>
154 ::End() const
155 {
156  return ConstIterator(m_InternalArray+VLength);
157 }
158 
159 
163 template <typename TValueType, unsigned int VLength>
167 {
168  return ReverseIterator(m_InternalArray+VLength);
169 }
170 
171 
175 template <typename TValueType, unsigned int VLength>
178 ::rBegin() const
179 {
180  return ConstReverseIterator(m_InternalArray+VLength);
181 }
182 
183 
187 template <typename TValueType, unsigned int VLength>
191 {
192  return ReverseIterator(m_InternalArray);
193 }
194 
195 
199 template <typename TValueType, unsigned int VLength>
202 ::rEnd() const
203 {
204  return ConstReverseIterator(m_InternalArray);
205 }
206 
207 
211 template <typename TValueType, unsigned int VLength>
214 ::Size() const
215 {
216  return VLength;
217 }
218 
219 
223 template <typename TValueType, unsigned int VLength>
224 void
226 ::Fill(const ValueType& value)
227 {
228  Iterator i = this->Begin();
229  while( i != this->End() )
230  {
231  *(i++) = value;
232  }
233 }
234 
235 
239 template <typename TValueType, unsigned int VLength>
242 ::Filled(const ValueType& value)
243 {
245  array.Fill(value);
246  return array;
247 }
248 
249 template <typename TValueType, unsigned int VLength>
250 std::ostream & operator<<(std::ostream &os, const FixedArray<TValueType,VLength> &arr)
251 {
252  os << "[";
253  if ( VLength == 1 )
254  {
255  os << arr[0];
256  }
257  else
258  {
259  for (int i=0; i < static_cast<int>(VLength) - 1; ++i)
260  {
261  os << arr[i] << ", ";
262  }
263  os << arr[VLength-1];
264  }
265  os << "]";
266  return os;
267 }
268 
269 } // namespace itk
270 
271 #endif

Generated at Sat May 18 2013 23:39:19 for Orfeo Toolbox with doxygen 1.8.3.1