queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 numCols() const
Number of columns in the array.
unsigned int numRows() const
Number of rows in the array.
unsigned int m_numRows
std::vector< std::vector< T * > * > m_data
unsigned int m_numCols
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.

78 {
79  // FIXME - Should this really be active in optimized codes? - RHS
80  queso_require_less(i, m_numRows);
81  queso_require_less(j, m_numCols);
82  queso_require(m_data[i]);
83  queso_require((*m_data[i])[j]);
84 
85  return *(*(m_data[i]))[j];
86 }
unsigned int m_numRows
std::vector< std::vector< T * > * > m_data
unsigned int m_numCols
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.

90 {
91  // FIXME - Should this really be active in optimized codes? - RHS
92  queso_require_less(i, m_numRows);
93  queso_require_less(j, m_numCols);
94  queso_require(m_data[i]);
95  queso_require((*m_data[i])[j]);
96 
97  return *(*(m_data[i]))[j];
98 }
unsigned int m_numRows
std::vector< std::vector< T * > * > m_data
unsigned int m_numCols
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.

Referenced by QUESO::BaseVectorSequence< V, M >::computeAutoCorrViaDef(), QUESO::BaseVectorSequence< V, M >::computeAutoCorrViaFFT(), QUESO::BaseVectorSequence< V, M >::computeMeanStacc(), and QUESO::BaseVectorSequence< V, M >::computePSD().

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
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 Tue Jun 5 2018 19:49:19 for queso-0.57.1 by  doxygen 1.8.5