@@ -26,7 +26,7 @@ class CBasicImageFilterCommon
26
26
public:
27
27
using iterator_category = std::random_access_iterator_tag;
28
28
using difference_type = int64_t ;
29
- using value_type = const uint32_t * ;
29
+ using value_type = std::array< uint32_t ,batch_dims> ;
30
30
using pointer = const value_type*;
31
31
using reference = value_type;
32
32
@@ -35,17 +35,17 @@ class CBasicImageFilterCommon
35
35
BlockIterator ()
36
36
{
37
37
std::fill_n (extentBatches,batch_dims,0u );
38
- std::fill_n (batchCoord,batch_dims,0u );
38
+ std::fill_n (batchCoord. begin () ,batch_dims,0u );
39
39
}
40
40
explicit inline BlockIterator (const uint32_t * _extentBatches)
41
41
{
42
42
std::copy_n (_extentBatches,batch_dims,extentBatches);
43
- std::fill_n (batchCoord,batch_dims,0u );
43
+ std::fill_n (batchCoord. begin () ,batch_dims,0u );
44
44
}
45
45
explicit inline BlockIterator (const uint32_t * _extentBatches, const uint32_t * _batchCoord)
46
46
{
47
47
std::copy_n (_extentBatches,batch_dims,extentBatches);
48
- std::copy_n (_batchCoord,batch_dims,batchCoord);
48
+ std::copy_n (_batchCoord,batch_dims,batchCoord. begin () );
49
49
}
50
50
BlockIterator (const BlockIterator<batch_dims>& other) = default ;
51
51
BlockIterator (BlockIterator<batch_dims>&& other) = default ;
@@ -59,11 +59,9 @@ class CBasicImageFilterCommon
59
59
}
60
60
inline pointer operator ->() const {return &batchCoord;}
61
61
62
- inline value_type operator [] (int index)
62
+ inline value_type operator [] (int index) const
63
63
{
64
- BlockIterator<batch_dims> temp = BlockIterator<batch_dims>(this ->extentBatches );
65
- temp+=index;
66
- return *temp;
64
+ return *(operator +(index));
67
65
}
68
66
69
67
inline bool operator < (const BlockIterator<batch_dims>& _rhs) const
@@ -108,7 +106,7 @@ class CBasicImageFilterCommon
108
106
return copy;
109
107
}
110
108
111
- inline bool operator ==(const BlockIterator<batch_dims>& other) const {return std::equal (batchCoord,batchCoord+batch_dims ,other.batchCoord );}
109
+ inline bool operator ==(const BlockIterator<batch_dims>& other) const {return std::equal (batchCoord. begin () ,batchCoord. end () ,other.batchCoord . begin () );}
112
110
inline bool operator !=(const BlockIterator<batch_dims>& other) const {return !operator ==(other);}
113
111
114
112
inline BlockIterator<batch_dims>& operator +=(const difference_type advance)
@@ -134,7 +132,7 @@ class CBasicImageFilterCommon
134
132
inline const uint32_t * getExtentBatches () const {return extentBatches;}
135
133
private:
136
134
uint32_t extentBatches[batch_dims];
137
- uint32_t batchCoord[batch_dims] ;
135
+ value_type batchCoord;
138
136
139
137
140
138
explicit inline BlockIterator (const uint32_t * _extentBatches, difference_type linearAddress)
@@ -184,15 +182,15 @@ class CBasicImageFilterCommon
184
182
185
183
const auto strides = region.getByteStrides (blockInfo);
186
184
187
- auto batch1D = [&f,®ion,trueExtent,strides,trueOffset](const uint32_t * batchCoord)
185
+ auto batch1D = [&f,®ion,trueExtent,strides,trueOffset](const std::array< uint32_t , 3u >& batchCoord)
188
186
{
189
187
for (auto xBlock=0u ; xBlock<trueExtent.x ; ++xBlock)
190
188
{
191
189
const core::vectorSIMDu32 localCoord (xBlock,batchCoord[0 ],batchCoord[1 ],batchCoord[2 ]);
192
190
f (region.getByteOffset (localCoord,strides),localCoord+trueOffset);
193
191
}
194
192
};
195
- auto batch2D = [&f,®ion,trueExtent,strides,trueOffset](const uint32_t * batchCoord)
193
+ auto batch2D = [&f,®ion,trueExtent,strides,trueOffset](const std::array< uint32_t , 2u >& batchCoord)
196
194
{
197
195
for (auto yBlock=0u ; yBlock<trueExtent.y ; ++yBlock)
198
196
for (auto xBlock=0u ; xBlock<trueExtent.x ; ++xBlock)
@@ -201,7 +199,7 @@ class CBasicImageFilterCommon
201
199
f (region.getByteOffset (localCoord,strides),localCoord+trueOffset);
202
200
}
203
201
};
204
- auto batch3D = [&f,®ion,trueExtent,strides,trueOffset](const uint32_t * batchCoord)
202
+ auto batch3D = [&f,®ion,trueExtent,strides,trueOffset](const std::array< uint32_t , 1u >& batchCoord)
205
203
{
206
204
for (auto zBlock=0u ; zBlock<trueExtent.z ; ++zBlock)
207
205
for (auto yBlock=0u ; yBlock<trueExtent.y ; ++yBlock)
0 commit comments