29template<
typename T,
typename Index =
unsigned>
57 for (
size_t i = 0; i < _data.size(); ++i)
91 _rebuild_ptr_line((Index)b._ptrLine.size());
100 assert(j < _ptrLine.size());
101 return { _ptrLine[j], _w };
108 assert(j < _ptrLine.size());
109 return { _ptrLine[j], _w };
123 const T&
Get(Index j, Index i)
const
125 assert(j < _ptrLine.size());
127 return _ptrLine[j][i];
131 return Get(xy[1], xy[0]);
135 assert(j < _ptrLine.size());
137 return _ptrLine[j][i];
141 return GetRef(xy[1], xy[0]);
148 if (j >= _ptrLine.size()
151 return &_ptrLine[j][i];
160 if (xy_out[0] < 0 || xy_out[1] < 0)
162 return GetPointer((Index)xy_out[1], (Index)xy_out[0]);
165 void Set(Index j, Index i,
const T& v)
167 assert(j < _ptrLine.size());
177 for (
auto& iter : _data)
192 Index i_max = (std::min)(_w, b._w);
193 Index j_max = (Index)(std::min)(_ptrLine.size(), b._ptrLine.size());
194 for(Index j = 0; j < j_max; ++j)
195 for (Index i = 0; i < i_max; ++i)
206 assert(vec.size() == _w);
207 _data.insert(_data.end(), vec.begin(), vec.end());
208 _rebuild_ptr_line((Index)_ptrLine.size() + 1);
212 bool IsEmpty()
const {
return _data.empty(); }
216 return (
const std::byte*)_data.data();
236 return (Index)_ptrLine.size();
252 return (Index)(_data.size() *
sizeof(
T));
257 return _data.begin();
269 _data.emplace_back(t);
281 for (Index j = 0; j < v.
GetHeight(); ++j)
283 for (Index i = 0; i < v.
GetWidth(); ++i)
291 std::vector<T> _data;
293 std::vector<T*> _ptrLine;
299 _rebuild_ptr_line(
size[1]);
302 void _rebuild_ptr_line(Index h)
305 for (Index i = 0; i < _ptrLine.size(); ++i)
306 _ptrLine[i] = _data.data() + i * _w;
const std::byte * GetBuffer() const
void Resize(const Size &size)
调整为指定大小
void CopyCross(const Vector2 &b)
从b拷贝重复的面积
const T * GetData() const
void PushBack(std::vector< T > &vec)
插入行
T * GetPointerOffset(const PointU &xy, const Point &offset)
T * GetPointer(Index j, Index i)
返回元素地址,失败返回空
Vector2(const Size &size, const T *p)
以指定大小构造,并传入指针赋值初始化
T & GetRef(Index j, Index i)
const std::span< T > operator[](Index j) const
返回第j行
const T & Get(Index j, Index i) const
返回第j行 第i个
T & GetRef(const PointU &xy)
static Vector2 RotateRightAngle1(const Vector2 &v)
void Fill(const uint32_t &v)
T * GetPointer(const PointU &xy)
Vector2(const Size &size)
以指定大小构造
Vector2(const Vector2 &b)
复制构造 todo
const T & Get(const PointU &xy) const
std::span< T > operator[](Index j)
返回第j行
Vector2 & operator=(const Vector2 &b)
void Set(Index j, Index i, const T &v)
constexpr auto Mul(const C &container)
求积product
constexpr Array< Point::value_type, N > toPoint(const Array< T, N > &a)
转换到Point,已知长度