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

A BRIDGES array type. More...

#include <Array2D.h>

Inheritance diagram for bridges::datastructure::Array2D< E >:
bridges::datastructure::Array< E > bridges::datastructure::DataStructure

Classes

struct  Bracket_helper
 helper class to make [][] operators work on array 2d. You should never use it directly More...
 
struct  Bracket_helper_const
 helper class to make [][] operators work on array 2d. You should never use it directly More...
 

Public Member Functions

virtual ~Array2D ()
 
 Array2D (int rows, int cols)
 builds an array of given dimensions
 
int getNumRows ()
 
int getNumColumns ()
 Gets the number of columns of the 2D array.
 
Element< E > & getElement (int row, int col)
 
void setElement (int row, int col, Element< E > el)
 
Bracket_helper operator[] (int index)
 enables using the bracket [] operator
 
Bracket_helper_const operator[] (int index) const
 enables using the bracket [] operator
 
- Public Member Functions inherited from bridges::datastructure::Array< E >
virtual const string getDStype () const override
 
virtual const string getDataStructureRepresentation () const override final
 
 Array (const Array &)=delete
 
Arrayoperator= (const Array &)=delete
 
- Public Member Functions inherited from bridges::datastructure::DataStructure
virtual ~DataStructure ()=default
 

Additional Inherited Members

- Protected Member Functions inherited from bridges::datastructure::Array< E >
 Array ()
 
virtual ~Array ()
 
 Array (int sz)
 builds an array given the size
 
void setSize (int nd, int *dim)
 Set the size of the array.
 
void getDimensions (int *dim)
 Get the dimensions of the array.
 
int const * getDimensions () const
 
Element< E > & getElement (int index)
 
Element< E > const & getElement (int index) const
 Get the object at index index - 1D array.
 
void setElement (int ind, Element< E > el)
 Set the Element at index ind - 1D array.
 

Detailed Description

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

A BRIDGES array type.

This class can be used to create 2D arrays of any type.

The access to the values stored are done directly using bracket operators such as

arr [12][25] = "hello!";
A BRIDGES array type.
Definition Array2D.h:42

Entries in the array can be styled by showing a label and changing the color of an entry. This is achieved by styling the underlying element to a particular entry of the array such as:

arr.getElement(12, 25).setColor("yellow");
arr.getElement(12, 25).setLabel("Hi there");
See also
See tutorial at: https://bridgesuncc.github.io/tutorials/Array.html
Parameters
Ethe application data type
Author
Kalpathi Subramanian, Erik Saule
Date
7/16/19

Constructor & Destructor Documentation

◆ ~Array2D()

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

◆ Array2D()

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

builds an array of given dimensions

Parameters
rowsnumber of rows
colsnumber of cols

Member Function Documentation

◆ getElement()

template<typename E >
Element< E > & bridges::datastructure::Array2D< E >::getElement ( int  row,
int  col 
)
inline

Get the object at (row, col)

Parameters
row- row index
col- column index
Returns
Element<E> at (row, col)

◆ getNumColumns()

template<typename E >
int bridges::datastructure::Array2D< E >::getNumColumns ( )
inline

Gets the number of columns of the 2D array.

Returns
number of rows

◆ getNumRows()

template<typename E >
int bridges::datastructure::Array2D< E >::getNumRows ( )
inline

Gets the number of rows of the 2D array

Returns
number of rows

◆ operator[]() [1/2]

template<typename E >
Bracket_helper bridges::datastructure::Array2D< E >::operator[] ( int  index)
inline

enables using the bracket [] operator

◆ operator[]() [2/2]

template<typename E >
Bracket_helper_const bridges::datastructure::Array2D< E >::operator[] ( int  index) const
inline

enables using the bracket [] operator

◆ setElement()

template<typename E >
void bridges::datastructure::Array2D< E >::setElement ( int  row,
int  col,
Element< E >  el 
)
inline

Set the object at index row, col - 2D array

Parameters
row- row index into the array
col- column index into the array
el- Element object

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