Zivid C++ API 2.6.1+6cec8609-3
Defining the Future of 3D Machine Vision
Public Types | Public Member Functions | Friends | List of all members
Zivid::Array2D< DataFormat > Class Template Reference

Two-dimensional container of data More...

#include <Zivid/Array2D.h>

Public Types

using ValueType = DataFormat
 The type of the elements stored in the Array2D More...
 

Public Member Functions

 Array2D ()
 Create an empty Array2D More...
 
size_t width () const
 Get the width of the array (number of columns) More...
 
size_t height () const
 Get the height of the array (number of rows) More...
 
size_t size () const
 Get the number of elements in the array More...
 
bool isEmpty () const
 Check if the array is empty More...
 
const DataFormat * data () const
 Pointer to the first data element of the array More...
 
const DataFormat & operator() (size_t idx) const
 Constant reference to an element given by a 1D linear index More...
 
const DataFormat & operator() (size_t i, size_t j) const
 Constant reference to an element given by row and column More...
 
std::string toString () const
 Get array information as string More...
 

Friends

class Array2DFactory
 

Detailed Description

template<typename DataFormat>
class Zivid::Array2D< DataFormat >

Two-dimensional container of data

Array2D manages the data using implicit sharing via reference counting. Copy or assignment of an Array2D object is shallow (only a pointer to the data is copied), which makes copy/assignment of Array2D fast. The data stored in the array is deallocated when there are no Array2D instances pointing to it.

The type of the elements stored in the array is given by template parameter DataFormat. Elements are stored sequentially in row-major order. Use data to get a pointer to the first element (row 0, column 0).

Member Typedef Documentation

◆ ValueType

template<typename DataFormat >
using Zivid::Array2D< DataFormat >::ValueType = DataFormat

The type of the elements stored in the Array2D

Constructor & Destructor Documentation

◆ Array2D()

template<typename DataFormat >
Zivid::Array2D< DataFormat >::Array2D ( )
inline

Create an empty Array2D

Member Function Documentation

◆ data()

template<typename DataFormat >
const DataFormat * Zivid::Array2D< DataFormat >::data ( ) const
inline

Pointer to the first data element of the array

If the array is empty then this method returns nullptr

◆ height()

template<typename DataFormat >
size_t Zivid::Array2D< DataFormat >::height ( ) const
inline

Get the height of the array (number of rows)

◆ isEmpty()

template<typename DataFormat >
bool Zivid::Array2D< DataFormat >::isEmpty ( ) const
inline

Check if the array is empty

◆ operator()() [1/2]

template<typename DataFormat >
const DataFormat & Zivid::Array2D< DataFormat >::operator() ( size_t  i,
size_t  j 
) const
inline

Constant reference to an element given by row and column

Data is stored in row-major order. No bounds checking is performed. Calling this operator with an argument that is out of range causes undefined behavior. Calling this operator when the Array2D is empty causes undefined behavior.

Parameters
iRow, from 0 to height - 1
jColumn, from 0 to width - 1

◆ operator()() [2/2]

template<typename DataFormat >
const DataFormat & Zivid::Array2D< DataFormat >::operator() ( size_t  idx) const
inline

Constant reference to an element given by a 1D linear index

Data is stored in row-major order. No bounds checking is performed. Calling this operator with an argument that is out of range causes undefined behavior. Calling this operator when the Array2D is empty causes undefined behavior.

Parameters
idxIndex (from 0 to size - 1)

◆ size()

template<typename DataFormat >
size_t Zivid::Array2D< DataFormat >::size ( ) const
inline

Get the number of elements in the array

This is identical to width() * height()

◆ toString()

template<typename DataFormat >
std::string Zivid::Array2D< DataFormat >::toString ( ) const
inline

Get array information as string

◆ width()

template<typename DataFormat >
size_t Zivid::Array2D< DataFormat >::width ( ) const
inline

Get the width of the array (number of columns)

Friends And Related Function Documentation

◆ Array2DFactory

template<typename DataFormat >
friend class Array2DFactory
friend

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