queso-0.53.0
Private Attributes | List of all members
QUESO::TwoDArray< T > Class Template Reference

Class for handling arrays of generic data. More...

#include <2dArrayOfStuff.h>

Public Member Functions

Constructor/Destructor methods
 TwoDArray (unsigned int numRows, unsigned int numCols)
 Default constructor. More...
 
 ~TwoDArray ()
 Destructor. More...
 
Attribute methods
unsigned int numRows () const
 Number of rows in the array. More...
 
unsigned int numCols () const
 Number of columns in the array. More...
 
void setLocation (unsigned int i, unsigned int j, T *info)
 Sets the data in a specific location. More...
 
Accessor methods
T & operator() (unsigned int i, unsigned int j)
 Returns data stored in a specific location (non-const). More...
 
const T & operator() (unsigned int i, unsigned int j) const
 Returns data stored in a specific location (const). More...
 

Private Attributes

unsigned int m_numRows
 
unsigned int m_numCols
 
std::vector< std::vector< T * > * > m_data
 

Detailed Description

template<class T>
class QUESO::TwoDArray< T >

Class for handling arrays of generic data.

This class handles array of generic data (doubles, ints, strings, structs, etc.).

Definition at line 39 of file 2dArrayOfStuff.h.

Constructor & Destructor Documentation

template<class T >
QUESO::TwoDArray< T >::TwoDArray ( unsigned int  numRows,
unsigned int  numCols 
)

Default constructor.

Definition at line 32 of file 2dArrayOfStuff.C.

References QUESO::TwoDArray< T >::m_data, QUESO::TwoDArray< T >::m_numCols, and QUESO::TwoDArray< T >::m_numRows.

33  : m_numRows(numRows),
35  m_data (m_numRows,NULL)
36 {
37  for (unsigned int i = 0; i < m_numRows; ++i) {
38  m_data[i] = new std::vector<T*>(m_numCols,NULL);
39  }
40 }
unsigned int m_numRows
unsigned int numCols() const
Number of columns in the array.
std::vector< std::vector< T * > * > m_data
unsigned int m_numCols
unsigned int numRows() const
Number of rows in the array.
template<class T >
QUESO::TwoDArray< T >::~TwoDArray ( )

Destructor.

Definition at line 44 of file 2dArrayOfStuff.C.

45 {
46  for (unsigned int i = 0; i < m_numRows; ++i) {
47  for (unsigned int j = 0; j < m_numCols; ++j) {
48  if ((*(m_data[i]))[j] != NULL) delete (*(m_data[i]))[j];
49  }
50  delete m_data[i];
51  }
52 }
unsigned int m_numRows
std::vector< std::vector< T * > * > m_data
unsigned int m_numCols

Member Function Documentation

template<class T >
unsigned int QUESO::TwoDArray< T >::numCols ( ) const

Number of columns in the array.

Definition at line 62 of file 2dArrayOfStuff.C.

63 {
64  return m_numCols;
65 }
unsigned int m_numCols
template<class T >
unsigned int QUESO::TwoDArray< T >::numRows ( ) const

Number of rows in the array.

Definition at line 56 of file 2dArrayOfStuff.C.

57 {
58  return m_numRows;
59 }
unsigned int m_numRows
template<class T >
T & QUESO::TwoDArray< T >::operator() ( unsigned int  i,
unsigned int  j 
)

Returns data stored in a specific location (non-const).

This non-const method returns the generic (templated) data that is stored the position (i,j) of the array.

Definition at line 77 of file 2dArrayOfStuff.C.

References queso_require, and queso_require_less.

78 {
79  // FIXME - Should this really be active in optimized codes? - RHS
83  queso_require((*m_data[i])[j]);
84 
85  return *(*(m_data[i]))[j];
86 }
unsigned int m_numRows
#define queso_require(asserted)
Definition: asserts.h:124
std::vector< std::vector< T * > * > m_data
unsigned int m_numCols
#define queso_require_less(expr1, expr2)
Definition: asserts.h:133
template<class T >
const T & QUESO::TwoDArray< T >::operator() ( unsigned int  i,
unsigned int  j 
) const

Returns data stored in a specific location (const).

This const method returns the generic (templated) data that is stored the position (i,j) of the array.

Definition at line 89 of file 2dArrayOfStuff.C.

References queso_require, and queso_require_less.

90 {
91  // FIXME - Should this really be active in optimized codes? - RHS
95  queso_require((*m_data[i])[j]);
96 
97  return *(*(m_data[i]))[j];
98 }
unsigned int m_numRows
#define queso_require(asserted)
Definition: asserts.h:124
std::vector< std::vector< T * > * > m_data
unsigned int m_numCols
#define queso_require_less(expr1, expr2)
Definition: asserts.h:133
template<class T >
void QUESO::TwoDArray< T >::setLocation ( unsigned int  i,
unsigned int  j,
T *  info 
)

Sets the data in a specific location.

This method sets the generic (templated) data info, in the position (i,j) of the array.

Definition at line 68 of file 2dArrayOfStuff.C.

References queso_require_msg.

69 {
70  queso_require_msg(!((i >= m_numRows) || (j >= m_numCols) || (m_data[i] == NULL)), "invalid situation");
71  (*(m_data[i]))[j] = info;
72  return;
73 }
unsigned int m_numRows
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::vector< std::vector< T * > * > m_data
unsigned int m_numCols

Member Data Documentation

template<class T >
std::vector<std::vector<T*>* > QUESO::TwoDArray< T >::m_data
private

Definition at line 81 of file 2dArrayOfStuff.h.

Referenced by QUESO::TwoDArray< T >::TwoDArray().

template<class T >
unsigned int QUESO::TwoDArray< T >::m_numCols
private

Definition at line 79 of file 2dArrayOfStuff.h.

Referenced by QUESO::TwoDArray< T >::TwoDArray().

template<class T >
unsigned int QUESO::TwoDArray< T >::m_numRows
private

Definition at line 78 of file 2dArrayOfStuff.h.

Referenced by QUESO::TwoDArray< T >::TwoDArray().


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

Generated on Thu Jun 11 2015 13:52:35 for queso-0.53.0 by  doxygen 1.8.5