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

#include <Array2D.h>

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

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

Array2D<std::string> arr(19, 30);
arr [12][25] = "hello!";

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:

Array2D<std::string> arr(19, 30);
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

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 More...
 
int getNumRows ()
 
int getNumColumns ()
 Gets the number of columns of the 2D array. More...
 
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 More...
 
Bracket_helper_const operator[] (int index) const
 enables using the bracket [] operator More...
 
- 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 More...
 
void setSize (int nd, int *dim)
 Set the size of the array. More...
 
void getDimensions (int *dim)
 Get the dimensions of the array. More...
 
int const * getDimensions () const
 
Element< E > & getElement (int index)
 
Element< E > const & getElement (int index) const
 Get the object at index index - 1D array. More...
 
void setElement (int ind, Element< E > el)
 Set the Element at index ind - 1D array. More...
 

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: