nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
Array2D< T > Class Template Reference

Two-dimensional array. More...

#include <Array2D.hpp>

Public Member Functions

 Array2D (int width, int height)
 Creates a 2D array with width and height.
 
at (int x, int y)
 Returns element at x y.
 
void set (int x, int y, const T &value)
 
size_t width ()
 Width size of the array.
 
size_t height ()
 Height size of the array.
 

Detailed Description

template<class T>
class Array2D< T >

Two-dimensional array.

This class tries to be as simple as C's matrix handling and very extensible, with std::vector.

Note

Array's contents must be a type/class that has a constructor with no arguments.

So if you create your MyClass and want a 2D array of it, make sure MyClass() has a constructor that receive no arguments.

Definition at line 22 of file Array2D.hpp.

Constructor & Destructor Documentation

◆ Array2D()

template<class T >
Array2D< T >::Array2D ( int width,
int height )

Creates a 2D array with width and height.

Definition at line 58 of file Array2D.hpp.

◆ ~Array2D()

template<class T >
virtual Array2D< T >::~Array2D ( )
inlinevirtual

Definition at line 27 of file Array2D.hpp.

Member Function Documentation

◆ at()

template<class T >
T Array2D< T >::at ( int x,
int y )
inline

Returns element at x y.

Definition at line 30 of file Array2D.hpp.

◆ height()

template<class T >
size_t Array2D< T >::height ( )

Height size of the array.

Definition at line 73 of file Array2D.hpp.

◆ set()

template<class T >
void Array2D< T >::set ( int x,
int y,
const T & value )
inline

Definition at line 35 of file Array2D.hpp.

◆ width()

template<class T >
size_t Array2D< T >::width ( )

Width size of the array.

Definition at line 67 of file Array2D.hpp.


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