12 namespace datastructure {
37 for (
int j = 0; j < rows; j++) {
38 grid[j] =
new E[cols];
42 void deallocateGrid() {
44 for (
int i = 0; i <
gridSize[0]; i++) {
52 void checkRowCol(
int row,
int col)
const {
54 throw "invalid location in Grid";
98 :
Grid(size[0], size[1]) {
109 for (
int i = 0; i <
gridSize[0]; i++) {
110 for (
int j = 0; j <
gridSize[1]; j++) {
111 set (i, j, g.get(i, j));
127 if (this->gridSize[0] != g.gridSize[0] ||
128 this->gridSize[1] != g.gridSize[1] ) {
132 for (
int i = 0; i <
gridSize[0]; i++) {
133 for (
int j = 0; j <
gridSize[1]; j++) {
134 set (i, j, g.get(i, j));
151 cerr <<
"Grid Maximum Size (1080 x 1920) exceeded!\n"
152 <<
"Provided Size: " << rows <<
" x " << cols
153 <<
". Aborting" << endl << endl;
174 E
const&
get(
int row,
int col)
const {
175 checkRowCol(row, col);
177 return grid[row][col];
186 void set(
int row,
int col, E val) {
187 checkRowCol(row, col);
189 grid[row][col] = val;
207 return gr.
get(row, col);
230 gr.checkRowCol(row, col);
231 return gr.
grid[row][col];
This is the superclass of all data structure types in BRIDGES.
Definition: DataStructure.h:74
This BracketHelperConst is a helper class to get the [] operators to work.
Definition: Grid.h:198
E const & operator[](int col) const
Definition: Grid.h:206
BracketHelperConst(Grid< E > const &g, int r)
Definition: Grid.h:202
This BracketHelper is a helper class to get the [] operators to work. It is not intended to be used b...
Definition: Grid.h:221
BracketHelper(Grid< E > &g, int r)
Definition: Grid.h:225
E & operator[](int col)
Definition: Grid.h:229
This is a class in BRIDGES for representing an (n x n) grid.
Definition: Grid.h:30
virtual const string getDStype() const override
Return the data structure type.
Definition: Grid.h:69
void setDimensions(int rows, int cols)
Construct the grid given the dimensions.
Definition: Grid.h:147
Grid()
Definition: Grid.h:88
Grid & operator=(const Grid &g)
Definition: Grid.h:126
BracketHelperConst operator[](int row) const
provides the necessary abstraction to do something = grid[x][y];
Definition: Grid.h:212
Grid(int rows, int cols)
Grid constructor.
Definition: Grid.h:81
int gridSize[2]
Definition: Grid.h:61
virtual ~Grid()
Definition: Grid.h:119
E ** grid
Definition: Grid.h:59
int const * getDimensions()
Get dimenions of the grid.
Definition: Grid.h:164
void set(int row, int col, E val)
Set the grid value for the (row, col) element.
Definition: Grid.h:186
int maxGridSize[2]
Definition: Grid.h:62
Grid(int *size)
Grid constructor given size.
Definition: Grid.h:97
E const & get(int row, int col) const
Get the (row, col) element in the grid.
Definition: Grid.h:174
Grid(const Grid &g)
Grid constructor given an input grid.
Definition: Grid.h:107
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4