ITK
4.3.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Core
Common
include
itkFixedArray.h
Go to the documentation of this file.
1
/*=========================================================================
2
*
3
* Copyright Insight Software Consortium
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0.txt
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*=========================================================================*/
18
#ifndef __itkFixedArray_h
19
#define __itkFixedArray_h
20
21
#include "
itkMacro.h
"
22
23
namespace
itk
24
{
25
49
template
<
typename
TValueType,
unsigned
int
VLength = 3 >
50
class
FixedArray
51
{
52
public
:
54
itkStaticConstMacro(
Length
,
unsigned
int
, VLength);
55
57
itkStaticConstMacro(
Dimension
,
unsigned
int
, VLength);
58
60
typedef
TValueType
ValueType
;
61
63
typedef
ValueType
CArray
[VLength];
64
66
typedef
ValueType
*
Iterator
;
67
69
typedef
const
ValueType
*
ConstIterator
;
70
71
class
ConstReverseIterator;
72
77
class
ReverseIterator
78
{
79
public
:
80
explicit
ReverseIterator
(
Iterator
i):
m_Iterator
(i) {}
81
Iterator
operator++
() {
return
--
m_Iterator
; }
82
Iterator
operator++
(
int
) {
return
m_Iterator
--; }
83
Iterator
operator--
() {
return
++
m_Iterator
; }
84
Iterator
operator--
(
int
) {
return
m_Iterator
++; }
85
Iterator
operator->
()
const
{
return
(
m_Iterator
- 1 ); }
86
ValueType
&
operator*
()
const
{
return
*(
m_Iterator
- 1 ); }
87
bool
operator!=
(
const
ReverseIterator
& rit)
const
{
return
m_Iterator
!= rit.
m_Iterator
; }
88
bool
operator==
(
const
ReverseIterator
& rit)
const
{
return
m_Iterator
== rit.
m_Iterator
; }
89
90
private
:
91
Iterator
m_Iterator
;
92
friend
class
ConstReverseIterator
;
93
};
94
99
class
ConstReverseIterator
100
{
101
public
:
102
explicit
ConstReverseIterator
(
ConstIterator
i):
m_Iterator
(i) {}
103
ConstReverseIterator
(
const
ReverseIterator
& rit) {
m_Iterator
= rit.
m_Iterator
; }
104
ConstIterator
operator++
() {
return
--
m_Iterator
; }
105
ConstIterator
operator++
(
int
) {
return
m_Iterator
--; }
106
ConstIterator
operator--
() {
return
++
m_Iterator
; }
107
ConstIterator
operator--
(
int
) {
return
m_Iterator
++; }
108
ConstIterator
operator->
()
const
{
return
(
m_Iterator
- 1 ); }
109
const
ValueType
&
operator*
()
const
{
return
*(
m_Iterator
- 1 ); }
110
bool
operator!=
(
const
ConstReverseIterator
& rit)
const
{
return
m_Iterator
!= rit.
m_Iterator
; }
111
bool
operator==
(
const
ConstReverseIterator
& rit)
const
{
return
m_Iterator
== rit.
m_Iterator
; }
112
113
private
:
114
ConstIterator
m_Iterator
;
115
};
116
118
typedef
ValueType
*
pointer
;
119
121
typedef
const
ValueType
*
const_pointer
;
122
124
typedef
ValueType
&
reference
;
125
127
typedef
const
ValueType
&
const_reference
;
128
129
typedef
unsigned
int
SizeType
;
130
131
public
:
133
FixedArray
();
134
FixedArray
(
const
ValueType
r[VLength]);
135
FixedArray
(
const
ValueType
& r);
137
139
template
<
class
TFixedArrayValueType >
140
FixedArray
(
const
FixedArray< TFixedArrayValueType, VLength >
& r)
141
{
142
typename
FixedArray< TFixedArrayValueType, VLength >::ConstIterator
input = r.
Begin
();
143
Iterator
i = this->
Begin
();
144
while
( i != this->
End
() )
145
{
146
*i++ =
static_cast<
TValueType
>
( *input++ );
147
}
148
}
150
165
template
<
class
TFixedArrayValueType >
166
FixedArray
&
operator=
(
const
FixedArray< TFixedArrayValueType, VLength >
& r)
167
{
168
if
( (
void
*)r.
Begin
() == (
void
*)
m_InternalArray
) {
return
*
this
; }
169
typename
FixedArray< TFixedArrayValueType, VLength >::ConstIterator
input = r.
Begin
();
170
Iterator
i = this->
Begin
();
171
while
( i != this->
End
() )
172
{
173
*i++ =
static_cast<
TValueType
>
( *input++ );
174
}
175
return
*
this
;
176
}
178
179
FixedArray
&
operator=
(
const
ValueType
r[VLength]);
180
184
bool
operator==
(
const
FixedArray
& r)
const
;
185
186
bool
operator!=
(
const
FixedArray
& r)
const
187
{
return
!
operator==
(r); }
188
192
reference
operator[]
(
short
index) {
return
m_InternalArray
[index]; }
193
const_reference
operator[]
(
short
index)
const
{
return
m_InternalArray
[index]; }
194
reference
operator[]
(
unsigned
short
index) {
return
m_InternalArray
[index]; }
195
const_reference
operator[]
(
unsigned
short
index)
const
{
return
m_InternalArray
[index]; }
196
reference
operator[]
(
int
index) {
return
m_InternalArray
[index]; }
197
const_reference
operator[]
(
int
index)
const
{
return
m_InternalArray
[index]; }
198
reference
operator[]
(
unsigned
int
index) {
return
m_InternalArray
[index]; }
199
const_reference
operator[]
(
unsigned
int
index)
const
{
return
m_InternalArray
[index]; }
200
reference
operator[]
(
long
index) {
return
m_InternalArray
[index]; }
201
const_reference
operator[]
(
long
index)
const
{
return
m_InternalArray
[index]; }
202
reference
operator[]
(
unsigned
long
index) {
return
m_InternalArray
[index]; }
203
const_reference
operator[]
(
unsigned
long
index)
const
{
return
m_InternalArray
[index]; }
204
reference
operator[]
(
long
long
index) {
return
m_InternalArray
[index]; }
205
const_reference
operator[]
(
long
long
index)
const
{
return
m_InternalArray
[index]; }
206
reference
operator[]
(
unsigned
long
long
index) {
return
m_InternalArray
[index]; }
207
const_reference
operator[]
(
unsigned
long
long
index)
const
{
return
m_InternalArray
[index]; }
209
211
void
SetElement
(
unsigned
short
index,
const_reference
value)
212
{
m_InternalArray
[index] = value; }
213
const_reference
GetElement
(
unsigned
short
index)
const
{
return
m_InternalArray
[index]; }
215
217
ValueType
*
GetDataPointer
()
218
{
219
return
m_InternalArray
; \
220
}
221
222
const
ValueType
*
GetDataPointer
()
const
223
{
224
return
m_InternalArray
; \
225
}
226
228
Iterator
Begin
();
229
230
ConstIterator
Begin
()
const
;
231
232
Iterator
End
();
233
234
ConstIterator
End
()
const
;
235
236
ReverseIterator
rBegin
();
237
238
ConstReverseIterator
rBegin
()
const
;
239
240
ReverseIterator
rEnd
();
241
242
ConstReverseIterator
rEnd
()
const
;
243
244
SizeType
Size
()
const
;
245
246
void
Fill
(
const
ValueType
&);
247
248
private
:
250
CArray
m_InternalArray
;
251
252
public
:
253
254
static
FixedArray
Filled
(
const
ValueType
&);
255
};
256
257
template
<
typename
TValueType,
unsigned
int
VLength >
258
std::ostream & operator<<(std::ostream & os, const FixedArray< TValueType, VLength > & arr);
259
}
// namespace itk
260
261
#ifndef ITK_MANUAL_INSTANTIATION
262
#include "itkFixedArray.hxx"
263
#endif
264
265
#include "
itkNumericTraitsFixedArrayPixel.h
"
266
267
#endif
268
Generated on Sun Dec 9 2012 01:00:10 for ITK by
1.8.2