Fixed-size 2D grid storing values in column-major order.
More...
#include <spk_grid_2d.hpp>
|
| struct | ConstRow |
| | Immutable view over a single column in the grid. More...
|
| struct | Row |
| | Mutable view over a single column in the grid. More...
|
|
|
using | Unit = T |
| | Stored element type for each grid cell.
|
|
|
| Grid2D ()=default |
| | Constructs an empty grid with zero dimensions.
|
| | Grid2D (const spk::Vector2UInt &size, const Unit &fill=Unit{}) |
| | Builds a grid with the given dimensions and fill value.
|
| const spk::Vector2UInt & | size () const |
| | Returns the grid dimensions.
|
| size_t | width () const |
| | Reports the horizontal cell count.
|
| size_t | height () const |
| | Reports the vertical cell count.
|
| Unit & | operator() (size_t x, size_t y) |
| | Mutable access to a cell using column and row indices.
|
| const Unit & | operator() (size_t x, size_t y) const |
| | Read-only access to a cell using column and row indices.
|
| Row | operator[] (size_t x) |
| | Provides a mutable column slice.
|
| ConstRow | operator[] (size_t x) const |
| | Provides a read-only column slice.
|
| Unit * | data () |
| | Exposes the underlying contiguous buffer.
|
| const Unit * | data () const |
| | Exposes the underlying contiguous buffer (const overload).
|
template<typename T>
class spk::Grid2D< T >
Fixed-size 2D grid storing values in column-major order.
- Template Parameters
-
| T | Cell value type stored in the grid. |
grid(1, 1) = 5;
Fixed-size 2D grid storing values in column-major order.
Definition spk_grid_2d.hpp:20
size_t height() const
Reports the vertical cell count.
Definition spk_grid_2d.hpp:132
◆ Grid2D()
Builds a grid with the given dimensions and fill value.
- Parameters
-
| size | Width and height of the grid. |
| fill | Value used to initialize every cell. |
◆ data() [1/2]
Exposes the underlying contiguous buffer.
- Returns
- Pointer to the first stored element.
◆ data() [2/2]
Exposes the underlying contiguous buffer (const overload).
- Returns
- Const pointer to the first stored element.
◆ height()
Reports the vertical cell count.
- Returns
- Number of rows.
◆ operator()() [1/2]
Mutable access to a cell using column and row indices.
- Parameters
-
| x | Column index. |
| y | Row index. |
- Returns
- Reference to the requested cell.
◆ operator()() [2/2]
Read-only access to a cell using column and row indices.
- Parameters
-
| x | Column index. |
| y | Row index. |
- Returns
- Const reference to the requested cell.
◆ operator[]() [1/2]
Provides a mutable column slice.
- Parameters
-
- Returns
- Row proxy with operator[] access.
◆ operator[]() [2/2]
Provides a read-only column slice.
- Parameters
-
- Returns
- ConstRow proxy with operator[] access.
◆ size()
Returns the grid dimensions.
- Returns
- Vector where x is width and y is height.
◆ width()
Reports the horizontal cell count.
- Returns
- Number of columns.
The documentation for this class was generated from the following file: