CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
tmtt::Array2D< T > Class Template Reference

#include <Array2D.h>

Public Member Functions

 Array2D (unsigned int m, unsigned int n)
 
const Toperator() (unsigned int i, unsigned int j) const
 
Toperator() (unsigned int i, unsigned int j)
 

Private Attributes

std::vector< Tarray2D_
 
unsigned int m_
 
unsigned int n_
 

Detailed Description

template<typename T>
class tmtt::Array2D< T >

Definition at line 19 of file Array2D.h.

Constructor & Destructor Documentation

template<typename T>
tmtt::Array2D< T >::Array2D ( unsigned int  m,
unsigned int  n 
)
inline

Definition at line 22 of file Array2D.h.

22 : array2D_(m * n), m_{m}, n_{n} {}
unsigned int n_
Definition: Array2D.h:39
unsigned int m_
Definition: Array2D.h:39
std::vector< T > array2D_
Definition: Array2D.h:38

Member Function Documentation

template<typename T>
const T& tmtt::Array2D< T >::operator() ( unsigned int  i,
unsigned int  j 
) const
inline

Definition at line 24 of file Array2D.h.

24  {
25  if (i >= m_ || j >= n_)
26  throw cms::Exception("LogicError")
27  << "Array2D: indices out of range " << i << " " << j << " " << m_ << " " << n_;
28  return array2D_[i * n_ + j];
29  }
unsigned int n_
Definition: Array2D.h:39
unsigned int m_
Definition: Array2D.h:39
std::vector< T > array2D_
Definition: Array2D.h:38
template<typename T>
T& tmtt::Array2D< T >::operator() ( unsigned int  i,
unsigned int  j 
)
inline

Definition at line 31 of file Array2D.h.

31  {
32  // Non-const version of operator, without needing to duplicate code.
33  // (Scott Meyers trick).
34  return const_cast<T&>(std::as_const(*this)(i, j));
35  }
long double T

Member Data Documentation

template<typename T>
std::vector<T> tmtt::Array2D< T >::array2D_
private
template<typename T>
unsigned int tmtt::Array2D< T >::m_
private
template<typename T>
unsigned int tmtt::Array2D< T >::n_
private