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

#include <Grid.h>

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

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
EThere is a tutorial about Grid : https://bridgesuncc.github.io/tutorials/Grid.html

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

Protected Attributes

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

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::game::GameGrid, and bridges::datastructure::ColorGrid.

◆ 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: