2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
argos_lib::led::Array2D< T > Class Template Reference

Array2D representation where origin is at bottom left. More...

#include <panel.h>

Public Member Functions

 Array2D ()=delete
 Disable default constructor because we need dimensions.
 
 Array2D (unsigned width, unsigned height, T fillValue={})
 Construct a new Array2D object.
 
T & at (unsigned x, unsigned y)
 Get mutable reference to cell at a given coordinate.
 
const T & at (unsigned x, unsigned y) const
 Const reference to cell at a given coordinate. Useful to read a value and allowing the compiler to protect against modifications.
 
unsigned Width () const noexcept
 Cells in horizontal dimension.
 
unsigned Height () const noexcept
 Cells in vertical dimension.
 

Private Attributes

std::vector< std::vector< T > > m_cells
 2D grid of cells. Kept private in case we actually get an ND-Array that would be better than this vector of vectors
 

Detailed Description

template<typename T>
class argos_lib::led::Array2D< T >

Array2D representation where origin is at bottom left.

Constructor & Destructor Documentation

◆ Array2D() [1/2]

template<typename T >
argos_lib::led::Array2D< T >::Array2D ( )
delete

Disable default constructor because we need dimensions.

◆ Array2D() [2/2]

template<typename T >
argos_lib::led::Array2D< T >::Array2D ( unsigned  width,
unsigned  height,
fillValue = {} 
)
inline

Construct a new Array2D object.

Parameters
widthNumber of cells in horizontal axis
heightNumber of cells in vertical axis
fillValueInitial value for all cells

Member Function Documentation

◆ at() [1/2]

template<typename T >
T & argos_lib::led::Array2D< T >::at ( unsigned  x,
unsigned  y 
)
inline

Get mutable reference to cell at a given coordinate.

Note
This can throw an out_of_range exception if a cell is requested outside the bounds of the array dimensions.
Parameters
xCoordinate in x dimesion. 0 is leftmost cell.
yCoordinate in y dimension. 0 is bottommost cell.
Returns
Cell at specified coordinate

◆ at() [2/2]

template<typename T >
const T & argos_lib::led::Array2D< T >::at ( unsigned  x,
unsigned  y 
) const
inline

Const reference to cell at a given coordinate. Useful to read a value and allowing the compiler to protect against modifications.

Note
This can throw an out_of_range exception if a cell is requested outside the bounds of the array dimensions.
Parameters
xCoordinate in x dimesion. 0 is leftmost cell.
yCoordinate in y dimension. 0 is bottommost cell.
Returns
Cell at specified coordinate

◆ Height()

template<typename T >
unsigned argos_lib::led::Array2D< T >::Height ( ) const
inlinenoexcept

Cells in vertical dimension.

Returns
Array height in cells

◆ Width()

template<typename T >
unsigned argos_lib::led::Array2D< T >::Width ( ) const
inlinenoexcept

Cells in horizontal dimension.

Returns
Array width in cells

Member Data Documentation

◆ m_cells

template<typename T >
std::vector<std::vector<T> > argos_lib::led::Array2D< T >::m_cells
private

2D grid of cells. Kept private in case we actually get an ND-Array that would be better than this vector of vectors


The documentation for this class was generated from the following file: