13template <
typename ElementData>
29 size_t width()
const {
return _width; }
34 size_t height()
const {
return _height; }
56 bool isEmpty()
const {
return _height == 0; }
67 std::shared_ptr<ElementData> pNewData(
new ElementData[_width *
height],
68 [](ElementData* p) {
delete[] p; });
70 memcpy(pNewData.get(), _pData.get(), _width * _height *
sizeof(ElementData));
73 _pData = std::move(pNewData);
81 if (_width !=
data.width())
84 if (_capacity - _height <
data.height()) {
87 memcpy(_pData.get() + _height * _width,
data.data(),
88 data.height() *
data.width() *
sizeof(ElementData));
89 _height +=
data.height();
96 const ElementData*
data()
const {
return _pData.get(); }
101 ElementData*
data() {
return _pData.get(); }
111 if (n >= _height * _width || !_pData)
112 throw std::out_of_range(
"invalid subscript");
113 ElementData*
data = _pData.get();
136 const ElementData&
at(uint32_t row, uint32_t col)
const
138 if (row >= _height || col >= _width || !_pData)
139 throw std::out_of_range(
"invalid subscript");
140 ElementData*
data = _pData.get();
141 return data[row * _width + col];
152 ElementData&
at(
size_t row,
size_t col)
154 return const_cast<ElementData&
>(
165 memcpy(copy.
data(),
data(), _height * _width *
sizeof(ElementData));
175 memset(_pData.get(), 0, _height * _width *
sizeof(ElementData));
183 std::shared_ptr<ElementData> _pData;
Represents the data struct of the profile data.
const ElementData & at(uint32_t row, uint32_t col) const
Returns a const element reference to the specified row and column index in the BatchArray object.
ElementData & operator[](std::size_t n)
Returns an element reference to the specified index in the BatchArray object using the operator [].
void clear()
Clears the data of the BatchArray object.
BatchArray(size_t width)
Describes a constructor.
ElementData * data()
Returns the pointer to the element data.
const ElementData * data() const
Returns the pointer to the element data.
size_t height() const
Returns the height of the BatchArray object.
bool isEmpty() const
Returns true if the BatchArray object has no elements.
size_t width() const
Returns the width of the BatchArray object.
bool append(const BatchArray &data)
Appends the data variable onto the end of this BatchArray object.
BatchArray< ElementData > clone() const
Creates a deep copy of the BatchArray object.
void reserve(size_t height)
Requests for enough capacity of the BatchArray object to contain the number of lines corresponding to...
size_t capacity() const
Returns the size of the storage space currently allocated for the BatchArray object,...
ElementData & at(size_t row, size_t col)
Returns an element reference to the specified row and column index in the BatchArray object.
const ElementData & operator[](std::size_t n) const
Returns a const element reference to the specified index in the BatchArray object using the operator ...
~BatchArray()=default
Describes a destructor.
void setHeight(size_t height)
Sets the height of the BatchArray object.