9 #ifndef CUBBYFLOW_ARRAY2_IMPL_H 10 #define CUBBYFLOW_ARRAY2_IMPL_H 26 Resize(size, initVal);
32 Resize(width, height, initVal);
50 *
this = std::move(other);
56 for (
auto& v : m_data)
65 m_data.resize(other.m_data.size());
66 std::copy(other.m_data.begin(), other.m_data.end(), m_data.begin());
67 m_size = other.m_size;
73 size_t height = list.size();
74 size_t width = (height > 0) ? list.begin()->size() : 0;
76 Resize(
Size2(width, height));
78 auto rowIter = list.begin();
79 for (
size_t j = 0; j < height; ++j)
81 assert(width == rowIter->size());
83 auto colIter = rowIter->begin();
84 for (
size_t i = 0; i < width; ++i)
86 (*this)(i, j) = *colIter;
101 template <
typename T>
105 grid.m_data.resize(size.
x * size.
y, initVal);
108 size_t iMin = std::min(size.
x, m_size.x);
109 size_t jMin = std::min(size.
y, m_size.y);
110 for (
size_t j = 0; j < jMin; ++j)
112 for (
size_t i = 0; i < iMin; ++i)
114 grid(i, j) = At(i, j);
121 template <
typename T>
124 Resize(
Size2(width, height), initVal);
127 template <
typename T>
130 assert(i < Width() * Height());
134 template <
typename T>
137 assert(i < Width() * Height());
141 template <
typename T>
144 return At(pt.
x, pt.
y);
147 template <
typename T>
150 return At(pt.
x, pt.
y);
153 template <
typename T>
156 assert(i < Width() && j < Height());
157 return m_data[i + Width() * j];
160 template <
typename T>
163 assert(i < Width() && j < Height());
164 return m_data[i + Width() * j];
167 template <
typename T>
173 template <
typename T>
179 template <
typename T>
185 template <
typename T>
188 return m_data.data();
191 template <
typename T>
194 return m_data.data();
197 template <
typename T>
200 return m_data.begin();
203 template <
typename T>
206 return m_data.cbegin();
209 template <
typename T>
215 template <
typename T>
218 return m_data.cend();
221 template <
typename T>
227 template <
typename T>
233 template <
typename T>
236 std::swap(other.m_data, m_data);
237 std::swap(other.m_size, m_size);
240 template <
typename T>
241 template <
typename Callback>
244 ConstAccessor().ForEach(func);
247 template <
typename T>
248 template <
typename Callback>
251 ConstAccessor().ForEachIndex(func);
254 template <
typename T>
255 template <
typename Callback>
258 Accessor().ParallelForEach(func);
261 template <
typename T>
262 template <
typename Callback>
265 ConstAccessor().ParallelForEachIndex(func);
268 template <
typename T>
274 template <
typename T>
280 template <
typename T>
283 assert(i < Width() && j < Height());
284 return m_data[i + Width() * j];
287 template <
typename T>
290 assert(i < Width() && j < Height());
291 return m_data[i + Width() * j];
294 template <
typename T>
297 assert(pt.
x < Width() && pt.
y < Height());
298 return m_data[pt.
x + Width() * pt.
y];
301 template <
typename T>
304 assert(pt.
x < Width() && pt.
y < Height());
305 return m_data[pt.
x + Width() * pt.
y];
308 template <
typename T>
315 template <
typename T>
322 template <
typename T>
325 m_data = std::move(other.m_data);
326 m_size = other.m_size;
327 other.m_size =
Size2();
331 template <
typename T>
338 template <
typename T>
344 template <
typename T>
347 return ConstAccessor();
2-D read-only array accessor class.
Definition: ArrayAccessor2.h:261
T x
X (or the first) component of the point.
Definition: Point2.h:28
2-D point class.
Definition: Point2.h:25
2-D array accessor class.
Definition: ArrayAccessor2.h:31
Point2< size_t > Size2
Definition: Size2.h:16
T y
Y (or the second) component of the point.
Definition: Point2.h:34
Definition: pybind11Utils.h:24
Generic N-dimensional array class interface.
Definition: Array.h:28
const T & At(const Point2UI &pt) const
Returns the const reference to the element at (pt.x, pt.y).
Definition: Array2-Impl.h:148
2-D array class.
Definition: Array2.h:42