Bridges-C++ 3.5.1
Bridges(C++ API)
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Attributes | List of all members
bridges::datastructure::Grid< E > Class Template Reference

This is a class in BRIDGES for representing an (n x n) grid. More...

#include <Grid.h>

Inheritance diagram for bridges::datastructure::Grid< E >:
bridges::datastructure::DataStructure

Classes

class  BracketHelper
 This BracketHelper is a helper class to get the [] operators to work. It is not intended to be used by bridges users. More...
 
class  BracketHelperConst
 This BracketHelperConst is a helper class to get the [] operators to work. More...
 

Public Member Functions

virtual const string getDStype () const override
 Return the data structure type.
 
 Grid (int rows, int cols)
 Grid constructor.
 
 Grid ()
 
 Grid (int *size)
 Grid constructor given size.
 
 Grid (const Grid &g)
 Grid constructor given an input grid.
 
virtual ~Grid ()
 
Gridoperator= (const Grid &g)
 
void setDimensions (int rows, int cols)
 Construct the grid given the dimensions.
 
int const * getDimensions ()
 Get dimenions of the grid.
 
E const & get (int row, int col) const
 Get the (row, col) element in the grid.
 
void set (int row, int col, E val)
 Set the grid value for the (row, col) element.
 
BracketHelperConst operator[] (int row) const
 provides the necessary abstraction to do something = grid[x][y];
 
BracketHelper operator[] (int row)
 provides the necessary abstraction to do grid[x][y] = something;
 
- Public Member Functions inherited from bridges::datastructure::DataStructure
virtual ~DataStructure ()=default
 

Protected Attributes

E ** grid = nullptr
 
int gridSize [2]
 
int maxGridSize [2] = {1080, 1920}
 

Detailed Description

template<typename E>
class bridges::datastructure::Grid< E >

This is a class in BRIDGES for representing an (n x n) grid.

This class will be useful in applications such as image processing, board games, etc.

Author
David Burlinson, Kalpathi Subramanian
Date
7/12/19, 12/28/20
Parameters
E

There is a tutorial about Grid : https://bridgesuncc.github.io/tutorials/Grid.html

Constructor & Destructor Documentation

◆ Grid() [1/4]

template<typename E >
bridges::datastructure::Grid< E >::Grid ( int  rows,
int  cols 
)
inline

Grid constructor.

Parameters
rowsheight of grid
colswidth of grid

◆ Grid() [2/4]

template<typename E >
bridges::datastructure::Grid< E >::Grid ( )
inline

default constructor

◆ Grid() [3/4]

template<typename E >
bridges::datastructure::Grid< E >::Grid ( int *  size)
inlineexplicit

Grid constructor given size.

Parameters
sizesize of grid

◆ Grid() [4/4]

template<typename E >
bridges::datastructure::Grid< E >::Grid ( const Grid< E > &  g)
inline

Grid constructor given an input grid.

copy the provided grid as input

Parameters
ginput grid

◆ ~Grid()

template<typename E >
virtual bridges::datastructure::Grid< E >::~Grid ( )
inlinevirtual

Destructor

Member Function Documentation

◆ get()

template<typename E >
E const & bridges::datastructure::Grid< E >::get ( int  row,
int  col 
) const
inline

Get the (row, col) element in the grid.

Parameters
rowheight of grid
colwidth of grid
Returns
the element at row, col

◆ getDimensions()

template<typename E >
int const * bridges::datastructure::Grid< E >::getDimensions ( )
inline

Get dimenions of the grid.

Returns
the grid height and width

◆ getDStype()

template<typename E >
virtual const string bridges::datastructure::Grid< E >::getDStype ( ) const
inlineoverridevirtual

Return the data structure type.

Returns
grid type (string)

Implements bridges::datastructure::DataStructure.

Reimplemented in bridges::datastructure::ColorGrid, and bridges::game::GameGrid.

◆ operator=()

template<typename E >
Grid & bridges::datastructure::Grid< E >::operator= ( const Grid< E > &  g)
inline

copy constructor

◆ operator[]() [1/2]

template<typename E >
BracketHelper bridges::datastructure::Grid< E >::operator[] ( int  row)
inline

provides the necessary abstraction to do grid[x][y] = something;

◆ operator[]() [2/2]

template<typename E >
BracketHelperConst bridges::datastructure::Grid< E >::operator[] ( int  row) const
inline

provides the necessary abstraction to do something = grid[x][y];

◆ set()

template<typename E >
void bridges::datastructure::Grid< E >::set ( int  row,
int  col,
val 
)
inline

Set the grid value for the (row, col) element.

Parameters
rowheight of grid
colwidth of grid
valvalue to be set

◆ setDimensions()

template<typename E >
void bridges::datastructure::Grid< E >::setDimensions ( int  rows,
int  cols 
)
inline

Construct the grid given the dimensions.

Parameters
rowsheight of grid
colswidth of grid

Member Data Documentation

◆ grid

template<typename E >
E** bridges::datastructure::Grid< E >::grid = nullptr
protected

◆ gridSize

template<typename E >
int bridges::datastructure::Grid< E >::gridSize[2]
protected

◆ maxGridSize

template<typename E >
int bridges::datastructure::Grid< E >::maxGridSize[2] = {1080, 1920}
protected

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