|
| Array2D () |
| Default constructor. More...
|
|
| Array2D (Vector< I, 2 > size) |
| Constructor with a size. More...
|
|
| Array2D (Vector< I, 2 > size, const T &value) |
| Constructor with a size and a value. More...
|
|
| Array2D (const Array2D &)=default |
| Default copy constructor. More...
|
|
Array2D & | operator= (const Array2D &)=default |
| Default copy assignment. More...
|
|
| Array2D (Array2D &&)=default |
| Default move constructor. More...
|
|
Array2D & | operator= (Array2D &&)=default |
| Default move assignement. More...
|
|
void | swap (Array2D &other) |
| Swap with another array. More...
|
|
|
const T * | getDataPtr () const noexcept |
| Get the pointer to raw data. More...
|
|
std::size_t | getDataSize () const noexcept |
| Get the raw data size. More...
|
|
constexpr bool | isEmpty () const noexcept |
| Check if the array is empty. More...
|
|
|
T & | operator() (Vector< I, 2 > pos) |
| Get the element at a given 2D position. More...
|
|
T & | operator() (std::size_t index) |
| Get the element at a given 1D index. More...
|
|
const T & | operator() (Vector< I, 2 > pos) const |
| Get the element at a given 2D position. More...
|
|
const T & | operator() (std::size_t index) const |
| Get the element at a given 1D index. More...
|
|
|
const T * | begin () const noexcept |
| Get an iterator to the first element of the array. More...
|
|
const T * | end () const noexcept |
| Get an iterator to the element following the last element of the array. More...
|
|
T * | begin () noexcept |
| Get an iterator to the first element of the array. More...
|
|
T * | end () noexcept |
| Get an iterator to the element following the last element of the array. More...
|
|
| Index2D () |
| Default constructor. More...
|
|
| Index2D (Vector< unsigned, 2 > size) |
| Constructor with a size. More...
|
|
| Index2D (const Index2D &)=default |
| Default copy constructor. More...
|
|
| Index2D (Index2D &&)=default |
| Default move constructor. More...
|
|
Index2D & | operator= (const Index2D &)=default |
| Default copy assignment. More...
|
|
Index2D & | operator= (Index2D &&)=default |
| Default move assignement. More...
|
|
void | swap (Index2D &other) |
| Swap with another array. More...
|
|
constexpr Vector< unsigned, 2 > | getSize () const noexcept |
| Get the size of the array. More...
|
|
constexpr unsigned | getCols () const noexcept |
| Get the number of columns. More...
|
|
constexpr unsigned | getRows () const noexcept |
| Get the number of rows. More...
|
|
constexpr bool | isValid (Vector< unsigned, 2 > pos) const noexcept |
| Check if a position is valid. More...
|
|
constexpr Vector< unsigned, 2 > | toPosition (std::size_t index) const noexcept |
| Transform a 1D position into a 2D position. More...
|
|
constexpr std::size_t | toIndex (Vector< unsigned, 2 > pos) const noexcept |
| Transform a 2D position into a 1D position. More...
|
|
constexpr RangeZ | getIndexRange () const noexcept |
| Get the 1D index range of the array. More...
|
|
constexpr Range< unsigned > | getRowRange () const noexcept |
| Get the row range. More...
|
|
constexpr Range< unsigned > | getColRange () const noexcept |
| Get the column range. More...
|
|
constexpr PositionRange< unsigned > | getPositionRange () const noexcept |
| Get the position range. More...
|
|
NeighborSquareRange< unsigned > | get8NeighborsRange (Vector< unsigned, 2 > pos) const noexcept |
| Get a range for 8 neighbors (at most) More...
|
|
NeighborSquareRange< unsigned > | get24NeighborsRange (Vector< unsigned, 2 > pos) const noexcept |
| Get a range for 24 neighbors (at most) More...
|
|
NeighborDiamondRange< unsigned > | get4NeighborsRange (Vector< unsigned, 2 > pos) const noexcept |
| Get a range for 4 neighbors (at most) More...
|
|
NeighborDiamondRange< unsigned > | get12NeighborsRange (Vector< unsigned, 2 > pos) const noexcept |
| Get a range for 12 neighbors (at most) More...
|
|
template<typename T, typename I = unsigned>
class gf::Array2D< T, I >
A two-dimensional array.
gf::Array represents a two-dimensional array, organized in row-major order.
The array is templated with the type of the data and the type of the indices (defaults to unsigned
).
Contrary to the usual way of accessing 2D arrays, the first coordinate is the column and the second coordinate is the row. So that, if size
is the size of the array and pos
is the position in the array:
- \( 0 \leq \mathtt{pos.x} = \mathtt{pos.col} < \mathtt{size.width} = \mathtt{size.col} \)
- \( 0 \leq \mathtt{pos.y} = \mathtt{pos.row} < \mathtt{size.height} = \mathtt{size.row} \)
Some convinient visitors are provided to visit the four neighbors (up, down, left and right), or the eight neighbors.
- See also
- gf::Matrix