The blo Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
blo::Array2D< T > Class Template Reference

2D array. More...

#include <Array2D.h>

Inheritance diagram for blo::Array2D< T >:
blo::Matrix< T >

Public Member Functions

 Array2D ()=default
 Default constructor.
 
 Array2D (int rows, int columns)
 Constructs array of specified size.
 
 Array2D (int rows, int columns, const T &val)
 Constructs array of specified size and value.
 
 Array2D (const T *pSrc, int srcStride1, int rows, int columns)
 Constructs array that is a copy of specified array.
 
 Array2D (const T *pSrc, int srcStride1, int srcStride2, int rows, int columns)
 Constructs array that is a copy of specified array.
 
 Array2D (const Array2D &rhs)
 Copy constructor.
 
 Array2D (Array2D &&rhs) noexcept
 Move constructor.
 
virtual ~Array2D ()
 Destructor.
 
Array2D & operator= (const Array2D &rhs)
 Copy assignment operator.
 
Array2D & operator= (Array2D &&rhs) noexcept
 Move assignment operator.
 
T * operator[] (int row)
 Index array row.
 
const T * operator[] (int row) const
 Index array row.
 
bool empty () const
 Tests if the array is empty.
 
void resize (int rows, int columns)
 Resizes array.
 
void clear ()
 Resizes array to zero rows and zero columns.
 
int rows () const
 Number of rows in the array.
 
int height () const
 Height of the array.
 
int columns () const
 Number of columns in the array.
 
int width () const
 Width of the array.
 
T * ptrData ()
 Retrieves the pointer to the beginning of the array.
 
const T * ptrData () const
 Retrieves the pointer to the beginning of the array.
 
int stride1 () const
 Stride in bytes between the rows in the array.
 
int step () const
 Step in bytes between the rows in the array.
 
int ld () const
 Leading dimension between the rows in the array.
 
void swap (Array2D &rhs)
 Swaps this array with another one.
 
void set (const T &val)
 Sets array elements to a value.
 

Static Public Member Functions

static int stride2 ()
 Stride in bytes between the elements in the array.
 

Detailed Description

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

2D array.

Template Parameters
TData type.

Constructor & Destructor Documentation

◆ Array2D() [1/7]

template<typename T >
blo::Array2D< T >::Array2D ( )
default

Default constructor.

◆ Array2D() [2/7]

template<typename T >
blo::Array2D< T >::Array2D ( int  rows,
int  columns 
)

Constructs array of specified size.

Parameters
rowsNumber of rows in the array.
columnsNumber of columns in the array.

◆ Array2D() [3/7]

template<typename T >
blo::Array2D< T >::Array2D ( int  rows,
int  columns,
const T &  val 
)

Constructs array of specified size and value.

Parameters
rowsNumber of rows in the array.
columnsNumber of columns in the array.
valConstant value to assign to each element in the array.

◆ Array2D() [4/7]

template<typename T >
blo::Array2D< T >::Array2D ( const T *  pSrc,
int  srcStride1,
int  rows,
int  columns 
)

Constructs array that is a copy of specified array.

Parameters
pSrcPointer to the source array.
srcStride1Stride in bytes between the rows in the source array.
rowsNumber of rows in the array.
columnsNumber of columns in the array.

◆ Array2D() [5/7]

template<typename T >
blo::Array2D< T >::Array2D ( const T *  pSrc,
int  srcStride1,
int  srcStride2,
int  rows,
int  columns 
)

Constructs array that is a copy of specified array.

Parameters
pSrcPointer to the source array.
srcStride1Stride in bytes between the rows in the source array.
srcStride2Stride in bytes between the elements in the source array.
rowsNumber of rows in the array.
columnsNumber of columns in the array.

◆ Array2D() [6/7]

template<typename T >
blo::Array2D< T >::Array2D ( const Array2D< T > &  rhs)

Copy constructor.

◆ Array2D() [7/7]

template<typename T >
blo::Array2D< T >::Array2D ( Array2D< T > &&  rhs)
noexcept

Move constructor.

◆ ~Array2D()

template<typename T >
virtual blo::Array2D< T >::~Array2D ( )
virtual

Destructor.

Member Function Documentation

◆ clear()

template<typename T >
void blo::Array2D< T >::clear ( )

Resizes array to zero rows and zero columns.

◆ columns()

template<typename T >
int blo::Array2D< T >::columns ( ) const

Number of columns in the array.

Returns
Number of columns in the array.

◆ empty()

template<typename T >
bool blo::Array2D< T >::empty ( ) const

Tests if the array is empty.

Returns
true if array is empty, false otherwise.

◆ height()

template<typename T >
int blo::Array2D< T >::height ( ) const

Height of the array.

Returns
Height of the array.

◆ ld()

template<typename T >
int blo::Array2D< T >::ld ( ) const

Leading dimension between the rows in the array.

Returns
Leading dimension between the rows in the array.

◆ operator=() [1/2]

template<typename T >
Array2D & blo::Array2D< T >::operator= ( Array2D< T > &&  rhs)
noexcept

Move assignment operator.

◆ operator=() [2/2]

template<typename T >
Array2D & blo::Array2D< T >::operator= ( const Array2D< T > &  rhs)

Copy assignment operator.

◆ operator[]() [1/2]

template<typename T >
T * blo::Array2D< T >::operator[] ( int  row)

Index array row.

Note
Index array element using array[row][column].
Parameters
rowRow of the array.
Returns
Pointer to the row.

◆ operator[]() [2/2]

template<typename T >
const T * blo::Array2D< T >::operator[] ( int  row) const

Index array row.

Note
Index array element using array[row][column].
Parameters
rowRow of the array.
Returns
Pointer to the row.

◆ ptrData() [1/2]

template<typename T >
T * blo::Array2D< T >::ptrData ( )

Retrieves the pointer to the beginning of the array.

Returns
Pointer to the beginning of the array.

◆ ptrData() [2/2]

template<typename T >
const T * blo::Array2D< T >::ptrData ( ) const

Retrieves the pointer to the beginning of the array.

Returns
Pointer to the beginning of the array.

◆ resize()

template<typename T >
void blo::Array2D< T >::resize ( int  rows,
int  columns 
)

Resizes array.

Parameters
rowsRows to resize array to.
columnsColumns to resize array to.

◆ rows()

template<typename T >
int blo::Array2D< T >::rows ( ) const

Number of rows in the array.

Returns
Number of rows in the array.

◆ set()

template<typename T >
void blo::Array2D< T >::set ( const T &  val)

Sets array elements to a value.

Parameters
valConstant value to assign to each element in the array.

◆ step()

template<typename T >
int blo::Array2D< T >::step ( ) const

Step in bytes between the rows in the array.

Returns
Step in bytes between the rows in the array.

◆ stride1()

template<typename T >
int blo::Array2D< T >::stride1 ( ) const

Stride in bytes between the rows in the array.

Returns
Stride in bytes between the rows in the array.

◆ stride2()

template<typename T >
static int blo::Array2D< T >::stride2 ( )
static

Stride in bytes between the elements in the array.

Returns
Stride in bytes between the elements in the array.

◆ swap()

template<typename T >
void blo::Array2D< T >::swap ( Array2D< T > &  rhs)

Swaps this array with another one.

◆ width()

template<typename T >
int blo::Array2D< T >::width ( ) const

Width of the array.

Returns
Width of the array.

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