29template<
typename T,
typename Index =
unsigned>
57 for (
size_t i = 0; i < _data.size(); ++i)
68 _rebuild_ptr_line((Index)b._ptrLine.size());
90 assert(j < _ptrLine.size());
91 return { _ptrLine[j], _w };
98 assert(j < _ptrLine.size());
99 return { _ptrLine[j], _w };
113 const T&
Get(Index j, Index i)
const
115 assert(j < _ptrLine.size());
117 return _ptrLine[j][i];
121 return Get(xy[1], xy[0]);
125 assert(j < _ptrLine.size());
127 return _ptrLine[j][i];
131 return GetRef(xy[1], xy[0]);
138 if (j >= _ptrLine.size()
141 return &_ptrLine[j][i];
150 if (xy_out[0] < 0 || xy_out[1] < 0)
152 return GetPointer((Index)xy_out[1], (Index)xy_out[0]);
155 void Set(Index j, Index i,
const T& v)
157 assert(j < _ptrLine.size());
167 for (
auto& iter : _data)
182 Index i_max = (std::min)(_w, b._w);
183 Index j_max = (Index)(std::min)(_ptrLine.size(), b._ptrLine.size());
184 for(Index j = 0; j < j_max; ++j)
185 for (Index i = 0; i < i_max; ++i)
196 assert(vec.size() == _w);
197 _data.insert(_data.end(), vec.begin(), vec.end());
198 _rebuild_ptr_line((Index)_ptrLine.size() + 1);
202 bool IsEmpty()
const {
return _data.empty(); }
206 return (
const std::byte*)_data.data();
226 return (Index)_ptrLine.size();
242 return (Index)(_data.size() *
sizeof(
T));
247 return _data.begin();
259 _data.emplace_back(t);
271 for (Index j = 0; j < v.
GetHeight(); ++j)
273 for (Index i = 0; i < v.
GetWidth(); ++i)
281 std::vector<T> _data;
283 std::vector<T*> _ptrLine;
289 _rebuild_ptr_line(
size[1]);
292 void _rebuild_ptr_line(Index h)
295 for (Index i = 0; i < _ptrLine.size(); ++i)
296 _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行
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,已知长度