15template <
typename ElementData>
31 size_t width()
const {
return _width; }
36 size_t height()
const {
return _height; }
68 if (
n >= _height * _width || !_pData)
69 throw std::out_of_range(
"invalid subscript");
95 if (
row >= _height ||
col >= _width || !_pData)
96 throw std::out_of_range(
"invalid subscript");
157 std::shared_ptr<ElementData> _pData;
Represents a 2D container of data.
size_t height() const
Returns the height of the Array2D object.
ElementData & operator[](std::size_t n)
Returns a reference to the constant element with the specified index in the Array2D object using the ...
const ElementData & operator[](std::size_t n) const
Returns a reference to the constant element with the specified index in the Array2D object using the ...
ElementData * data()
Returns the pointer to an element in the Array2D object. The returned pointer will be invalidated aft...
const ElementData & at(uint32_t row, uint32_t col) const
Returns a reference to the constant element at the specified row and column in the Array2D object.
Array2D< ElementData > clone() const
Creates a deep copy of the Array2D object.
void resize(size_t width, size_t height)
Changes the size of the Array2D object. It destroys the existing data and reallocates memory accordin...
const ElementData * data() const
Returns the pointer to an element in the Array2D object. The returned pointer will be invalidated aft...
ElementData & at(uint32_t row, uint32_t col)
Returns a reference to the element at the specified row and column in the Array2D object.
size_t width() const
Returns the width of the Array2D object.
bool isEmpty() const
Returns true if the Array2D object has no elements.
void release()
Deallocates the data in the Array2D object.
~Array2D()
Describes a destructor.