MINT2
Public Member Functions | Private Attributes | List of all members
MINT::TwoDArray< T > Class Template Reference

#include <TwoDArray.h>

Public Member Functions

unsigned int Nrow () const
 
unsigned int Ncol () const
 
unsigned int size () const
 
 TwoDArray (unsigned int Nrow, unsigned int Ncol)
 
 TwoDArray (unsigned int Nrow, unsigned int Ncol, T initValue)
 
 TwoDArray (const TwoDArray &other)
 
 ~TwoDArray ()
 
T * operator[] (unsigned int row)
 
const T * operator[] (unsigned int row) const
 
T * c_array ()
 
const T * c_array () const
 

Private Attributes

T * _m
 
unsigned int _Nrow
 
unsigned int _Ncol
 

Detailed Description

template<typename T>
class MINT::TwoDArray< T >

Definition at line 35 of file TwoDArray.h.

Constructor & Destructor Documentation

◆ TwoDArray() [1/3]

template<typename T>
MINT::TwoDArray< T >::TwoDArray ( unsigned int  Nrow,
unsigned int  Ncol 
)
inline

Definition at line 44 of file TwoDArray.h.

45  : _m(0), _Nrow(Nrow), _Ncol(Ncol){
46  _m = new T[size()];
47  }
unsigned int size() const
Definition: TwoDArray.h:42
unsigned int Ncol() const
Definition: TwoDArray.h:41
unsigned int _Ncol
Definition: TwoDArray.h:38
unsigned int _Nrow
Definition: TwoDArray.h:37
unsigned int Nrow() const
Definition: TwoDArray.h:40

◆ TwoDArray() [2/3]

template<typename T>
MINT::TwoDArray< T >::TwoDArray ( unsigned int  Nrow,
unsigned int  Ncol,
initValue 
)
inline

Definition at line 48 of file TwoDArray.h.

49  : _m(0), _Nrow(Nrow), _Ncol(Ncol){
50  _m = new T[size()];
51  for(unsigned int i=0; i < size(); i++) _m[i]=initValue;
52  }
unsigned int size() const
Definition: TwoDArray.h:42
unsigned int Ncol() const
Definition: TwoDArray.h:41
unsigned int _Ncol
Definition: TwoDArray.h:38
unsigned int _Nrow
Definition: TwoDArray.h:37
unsigned int Nrow() const
Definition: TwoDArray.h:40

◆ TwoDArray() [3/3]

template<typename T>
MINT::TwoDArray< T >::TwoDArray ( const TwoDArray< T > &  other)
inline

Definition at line 53 of file TwoDArray.h.

54  : _m(0), _Nrow(other._Nrow), _Ncol(other._Ncol){
55  _m = new T[size()];
56  for(unsigned int i = 0; i < size(); i++){
57  _m[i] = other._m[i];
58  }
59  }
unsigned int size() const
Definition: TwoDArray.h:42
unsigned int _Ncol
Definition: TwoDArray.h:38
unsigned int _Nrow
Definition: TwoDArray.h:37

◆ ~TwoDArray()

template<typename T>
MINT::TwoDArray< T >::~TwoDArray ( )
inline

Definition at line 61 of file TwoDArray.h.

61 {if(0 != _m) delete[] _m;}

Member Function Documentation

◆ c_array() [1/2]

template<typename T>
T* MINT::TwoDArray< T >::c_array ( )
inline

Definition at line 82 of file TwoDArray.h.

82  {
83  return _m;
84  }

◆ c_array() [2/2]

template<typename T>
const T* MINT::TwoDArray< T >::c_array ( ) const
inline

Definition at line 85 of file TwoDArray.h.

85  {
86  return _m;
87  }

◆ Ncol()

template<typename T>
unsigned int MINT::TwoDArray< T >::Ncol ( ) const
inline

Definition at line 41 of file TwoDArray.h.

41 {return _Ncol;}
unsigned int _Ncol
Definition: TwoDArray.h:38

◆ Nrow()

template<typename T>
unsigned int MINT::TwoDArray< T >::Nrow ( ) const
inline

Definition at line 40 of file TwoDArray.h.

40 {return _Nrow;}
unsigned int _Nrow
Definition: TwoDArray.h:37

◆ operator[]() [1/2]

template<typename T>
T* MINT::TwoDArray< T >::operator[] ( unsigned int  row)
inline

Definition at line 63 of file TwoDArray.h.

63  {
64  unsigned int n = row * _Ncol;
65  if(n >= size()){
66  std::cout << "array size error in Mint::TwoDArray"
67  << " row = " << row << ", n = " << n << std::endl;
68  throw "crap";
69  }
70  return &(_m[n]);
71  }
unsigned int size() const
Definition: TwoDArray.h:42
unsigned int _Ncol
Definition: TwoDArray.h:38

◆ operator[]() [2/2]

template<typename T>
const T* MINT::TwoDArray< T >::operator[] ( unsigned int  row) const
inline

Definition at line 72 of file TwoDArray.h.

72  {
73  unsigned int n = row * _Ncol;
74  if(n >= size()){
75  std::cout << "array size error in Mint::TwoDArray"
76  << " row = " << row << ", n = " << n << std::endl;
77  throw "crap";
78  }
79  return &(_m[n]);
80  }
unsigned int size() const
Definition: TwoDArray.h:42
unsigned int _Ncol
Definition: TwoDArray.h:38

◆ size()

template<typename T>
unsigned int MINT::TwoDArray< T >::size ( ) const
inline

Definition at line 42 of file TwoDArray.h.

42 {return _Nrow*_Ncol;}
unsigned int _Ncol
Definition: TwoDArray.h:38
unsigned int _Nrow
Definition: TwoDArray.h:37

Member Data Documentation

◆ _m

template<typename T>
T* MINT::TwoDArray< T >::_m
private

Definition at line 36 of file TwoDArray.h.

◆ _Ncol

template<typename T>
unsigned int MINT::TwoDArray< T >::_Ncol
private

Definition at line 38 of file TwoDArray.h.

◆ _Nrow

template<typename T>
unsigned int MINT::TwoDArray< T >::_Nrow
private

Definition at line 37 of file TwoDArray.h.


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