AMCAX Kernel 1.0.0.0
AMCAX::Array2< T > Class Template Reference

Template class of two dimensional array. More...

#include <common/Array2.hpp>

Public Types

using value_type = T
 Type of value.
 

Public Member Functions

 Array2 () noexcept=default
 Default constructor.
 
 Array2 (int nrow, int ncol)
 Construct an nrow x ncol array. More...
 
 Array2 (int nrow, int ncol, const T &initvalue)
 Construct an array with an initial value. More...
 
 ~Array2 () noexcept
 Destructor.
 
 Array2 (const Array2 &other)
 Copy constructor. More...
 
 Array2 (Array2 &&other) noexcept
 Move constructor. More...
 
Array2operator= (const Array2 &other)
 Copy assignment operator. More...
 
Array2operator= (Array2 &&other) noexcept
 Move assignement operator. More...
 
T * Data () noexcept
 Get the raw data pointer. More...
 
const T * Data () const noexcept
 Get the constant raw data pointer. More...
 
bool Empty () const noexcept
 Is the array empty. More...
 
void Clear () noexcept
 Clear the array.
 
int Size () const noexcept
 Get the total number of elements. More...
 
int NRow () const noexcept
 Get the number of rows. More...
 
int NCol () const noexcept
 Get the number of columns. More...
 
const T & operator() (int i, int j) const
 Get the element by indices. More...
 
T & operator() (int i, int j)
 Get the element by indices. More...
 
void Resize (int row, int col)
 Resize the array. More...
 
void Assign (int row, int col, const T &value)
 Assign the array with a value. More...
 
void Row (int i, std::vector< T > &data) const
 Get the row of given index. More...
 
void Col (int j, std::vector< T > &data) const
 Get the column of given index. More...
 
std::vector< T > Row (int i) const
 Get the row of given index. More...
 
std::vector< T > Col (int j) const
 Get the column of given index. More...
 
void FillRow (int i, const std::vector< T > &data)
 Fill the row of given index with given data. More...
 
void FillCol (int j, const std::vector< T > &data)
 Fill the column of given index with given data. More...
 

Detailed Description

template<typename T>
class AMCAX::Array2< T >

Template class of two dimensional array.

Template Parameters
TType of element

Constructor & Destructor Documentation

◆ Array2() [1/4]

template<typename T >
AMCAX::Array2< T >::Array2 ( int  nrow,
int  ncol 
)
inline

Construct an nrow x ncol array.

Parameters
nrowThe number of rows
ncolThe number of columns

◆ Array2() [2/4]

template<typename T >
AMCAX::Array2< T >::Array2 ( int  nrow,
int  ncol,
const T &  initvalue 
)
inline

Construct an array with an initial value.

Parameters
nrowThe number of rows
ncolThe number of columns
initvalueThe initial value

◆ Array2() [3/4]

template<typename T >
AMCAX::Array2< T >::Array2 ( const Array2< T > &  other)
inline

Copy constructor.

Parameters
otherThe other array

◆ Array2() [4/4]

template<typename T >
AMCAX::Array2< T >::Array2 ( Array2< T > &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThe other array

Member Function Documentation

◆ Assign()

template<typename T >
void AMCAX::Array2< T >::Assign ( int  row,
int  col,
const T &  value 
)
inline

Assign the array with a value.

Parameters
rowThe new number of rows
colThe new number of columns
valueThe value

◆ Col() [1/2]

template<typename T >
std::vector< T > AMCAX::Array2< T >::Col ( int  j) const
inline

Get the column of given index.

Parameters
jThe index of column
Returns
The column data

◆ Col() [2/2]

template<typename T >
void AMCAX::Array2< T >::Col ( int  j,
std::vector< T > &  data 
) const
inline

Get the column of given index.

Parameters
[in]jThe index of column
[out]dataThe column data

◆ Data() [1/2]

template<typename T >
const T * AMCAX::Array2< T >::Data ( ) const
inlinenoexcept

Get the constant raw data pointer.

Returns
The constant raw data pointer

◆ Data() [2/2]

template<typename T >
T * AMCAX::Array2< T >::Data ( )
inlinenoexcept

Get the raw data pointer.

Returns
The raw data pointer

◆ Empty()

template<typename T >
bool AMCAX::Array2< T >::Empty ( ) const
inlinenoexcept

Is the array empty.

Returns
True if the array is empty

◆ FillCol()

template<typename T >
void AMCAX::Array2< T >::FillCol ( int  j,
const std::vector< T > &  data 
)
inline

Fill the column of given index with given data.

Parameters
jThe index of column
dataThe column data

◆ FillRow()

template<typename T >
void AMCAX::Array2< T >::FillRow ( int  i,
const std::vector< T > &  data 
)
inline

Fill the row of given index with given data.

Parameters
iThe index of row
dataThe row data

◆ NCol()

template<typename T >
int AMCAX::Array2< T >::NCol ( ) const
inlinenoexcept

Get the number of columns.

Returns
The number of columns

◆ NRow()

template<typename T >
int AMCAX::Array2< T >::NRow ( ) const
inlinenoexcept

Get the number of rows.

Returns
The number of rows

◆ operator()() [1/2]

template<typename T >
T & AMCAX::Array2< T >::operator() ( int  i,
int  j 
)
inline

Get the element by indices.

Parameters
iThe row index
jThe column index
Returns
The element at (i, j)

◆ operator()() [2/2]

template<typename T >
const T & AMCAX::Array2< T >::operator() ( int  i,
int  j 
) const
inline

Get the element by indices.

Parameters
iThe row index
jThe column index
Returns
The element at (i, j)

◆ operator=() [1/2]

template<typename T >
Array2 & AMCAX::Array2< T >::operator= ( Array2< T > &&  other)
inlinenoexcept

Move assignement operator.

Parameters
otherThe other array
Returns
The reference to self

◆ operator=() [2/2]

template<typename T >
Array2 & AMCAX::Array2< T >::operator= ( const Array2< T > &  other)
inline

Copy assignment operator.

Parameters
otherThe other array
Returns
The reference to self

◆ Resize()

template<typename T >
void AMCAX::Array2< T >::Resize ( int  row,
int  col 
)
inline

Resize the array.

Parameters
rowNew number of rows
colNew number of columns

◆ Row() [1/2]

template<typename T >
std::vector< T > AMCAX::Array2< T >::Row ( int  i) const
inline

Get the row of given index.

Parameters
iThe index of row
Returns
The row data

◆ Row() [2/2]

template<typename T >
void AMCAX::Array2< T >::Row ( int  i,
std::vector< T > &  data 
) const
inline

Get the row of given index.

Parameters
[in]iThe index of row
[out]dataThe row data

◆ Size()

template<typename T >
int AMCAX::Array2< T >::Size ( ) const
inlinenoexcept

Get the total number of elements.

Returns
The size of array

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