# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

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

A template class for two-dimensional arrays. More...

`#include <arrays.h>`

Inheritance diagram for dirac::TwoDArray< T >:
[legend]

## Public Member Functions
| TwoDArray ()
| Default constructor. More...
| TwoDArray (const int height, const int width)
| Constructor. More...
| TwoDArray (const int height, const int width, T val)
| Constructor. More...
virtual | ~TwoDArray ()
| Destructor. More...
| TwoDArray (const TwoDArray< T > &Cpy)
| Copy constructor. More...
TwoDArray< T > & | operator= (const TwoDArray< T > &rhs)
| Assignment =. More...
bool | CopyContents (TwoDArray< T > &out) const
| Copy Contents. More...
void | Fill (T val)
| Fill contents. More...
void | Resize (const int height, const int width)
| Resizes the array, deleting the current data. More...
element_type & | operator[] (const int pos)
| Element access. More...
const element_type & | operator[] (const int pos) const
| Element access. More...
int | LengthX () const
| Returns the width. More...
int | LengthY () const
| Returns the height. More...
int | FirstX () const
| Returns the index of the first element of a row. More...
int | FirstY () const
| Returns the index of the first element of a column. More...
int | LastX () const
| Returns the index of the last element of a row. More...
int | LastY () const
| Returns the index of the first element of a column. More...

## Private Types
typedef T * | element_type

## Private Member Functions
void | Init (const int height, const int width)
| Initialise the array. More...
void | FreeData ()
| Free all the allocated data. More...

## Private Attributes
int | m_first_x
int | m_first_y
int | m_last_x
int | m_last_y
int | m_length_x
int | m_length_y
element_type * | m_array_of_rows

## Detailed Description

template<class T>
class dirac::TwoDArray< T >

A template class to do two-d arrays, so that explicit memory (de-)allocation is not required. Only zero-based arrays are currently supported so that access is fast. Accessing elements along a row is therefore much faster than accessing them along a column. Rows are contiguous in memory, so array[y][x] is equivalent to array[0][x+y*LengthX()].

## Member Typedef Documentation

## ◆ element_type

template<class T >

typedef T* dirac::TwoDArray< T >::element_type
| private

## Constructor & Destructor Documentation

## ◆ TwoDArray() [1/4]

template<class T >

dirac::TwoDArray< T >::TwoDArray | ( |  | ) |
| inline

Default constructor creates an empty array.

References dirac::TwoDArray< T >::Init().

## ◆ TwoDArray() [2/4]

template<class T >

dirac::TwoDArray< T >::TwoDArray | ( | const int | height,
|  | const int | width
| ) |  |
| inline

The constructor creates an array of given width height.

References dirac::TwoDArray< T >::Init().

## ◆ TwoDArray() [3/4]

template<class T >

dirac::TwoDArray< T >::TwoDArray | ( | const int | height,
|  | const int | width,
|  | T | val
| ) |  |

The constructor creates an array of given width and length height and initialises it to a value

## ◆ ~TwoDArray()

template<class T >

virtual dirac::TwoDArray< T >::~TwoDArray | ( |  | ) |
| inline virtual

Destructor frees the data allocated in the constructor.

References dirac::TwoDArray< T >::FreeData().

## ◆ TwoDArray() [4/4]

template<class T >

dirac::TwoDArray< T >::TwoDArray | ( | const TwoDArray< T > & | Cpy | ) |

Copy constructor copies data and metadata.

References dirac::TwoDArray< T >::m_array_of_rows, dirac::TwoDArray< T >::m_first_x, dirac::TwoDArray< T >::m_first_y, dirac::TwoDArray< T >::m_last_x, and dirac::TwoDArray< T >::m_last_y.

## Member Function Documentation

## ◆ CopyContents()

template<class T >

bool dirac::TwoDArray< T >::CopyContents | ( | TwoDArray< T > & | out | ) | const

Copy contents of array into output array retaining the dimensions of the output array. If output array is larger that array then pad with last true value. Return true is copy was successful

References dirac::TwoDArray< T >::m_array_of_rows, dirac::TwoDArray< T >::m_length_x, and dirac::TwoDArray< T >::m_length_y.

## ◆ Fill()

template<class T >

void dirac::TwoDArray< T >::Fill | ( | T | val | ) |

Initialise the array with the val provided.

## ◆ FirstX()

template<class T >

int dirac::TwoDArray< T >::FirstX | ( |  | ) | const
| inline

References dirac::TwoDArray< T >::m_first_x.

Referenced by dirac::GenericBandCodec< EntropyCodec >::DoWorkCode(), and dirac::GenericBandCodec< EntropyCodec >::DoWorkDecode().

## ◆ FirstY()

template<class T >

int dirac::TwoDArray< T >::FirstY | ( |  | ) | const
| inline

References dirac::TwoDArray< T >::m_first_y.

Referenced by dirac::GenericBandCodec< EntropyCodec >::DoWorkCode(), and dirac::GenericBandCodec< EntropyCodec >::DoWorkDecode().

## ◆ FreeData()

template<class T >

void dirac::TwoDArray< T >::FreeData
| private

Referenced by dirac::TwoDArray< T >::~TwoDArray().

## ◆ Init()

template<class T >

void dirac::TwoDArray< T >::Init | ( | const int | height,
|  | const int | width
| ) |  |
| private

Referenced by dirac::TwoDArray< T >::TwoDArray().

## ◆ LastX()

template<class T >

int dirac::TwoDArray< T >::LastX | ( |  | ) | const
| inline

References dirac::TwoDArray< T >::m_last_x.

Referenced by dirac::GenericBandCodec< EntropyCodec >::DoWorkCode(), and dirac::GenericBandCodec< EntropyCodec >::DoWorkDecode().

## ◆ LastY()

template<class T >

int dirac::TwoDArray< T >::LastY | ( |  | ) | const
| inline

References dirac::TwoDArray< T >::m_last_y.

Referenced by dirac::GenericBandCodec< EntropyCodec >::DoWorkCode(), and dirac::GenericBandCodec< EntropyCodec >::DoWorkDecode().

## ◆ LengthX()

template<class T >

int dirac::TwoDArray< T >::LengthX | ( |  | ) | const
| inline

References dirac::TwoDArray< T >::m_length_x.

Referenced by dirac::GenericBandCodec< EntropyCodec >::DoWorkCode(), dirac::GenericBandCodec< EntropyCodec >::DoWorkDecode(), dirac::operator<<(), and dirac::operator>>().

## ◆ LengthY()

template<class T >

int dirac::TwoDArray< T >::LengthY | ( |  | ) | const
| inline

References dirac::TwoDArray< T >::m_length_y.

Referenced by dirac::GenericBandCodec< EntropyCodec >::DoWorkCode(), dirac::GenericBandCodec< EntropyCodec >::DoWorkDecode(), dirac::operator<<(), and dirac::operator>>().

## ◆ operator=()

template<class T >

TwoDArray< T > & dirac::TwoDArray< T >::operator= | ( | const TwoDArray< T > & | rhs | ) |

Assignement = assigns both data and metadata.

References dirac::TwoDArray< T >::m_array_of_rows, dirac::TwoDArray< T >::m_first_x, dirac::TwoDArray< T >::m_first_y, dirac::TwoDArray< T >::m_last_x, and dirac::TwoDArray< T >::m_last_y.

## ◆ operator[]() [1/2]

template<class T >

element_type & dirac::TwoDArray< T >::operator[] | ( | const int | pos | ) |
| inline

Accesses the rows of the arrays, which are returned in the form of pointers to the row data NOT OneDArray objects.

References dirac::TwoDArray< T >::m_array_of_rows.

## ◆ operator[]() [2/2]

template<class T >

const element_type & dirac::TwoDArray< T >::operator[] | ( | const int | pos | ) | const
| inline

Accesses the rows of the arrays, which are returned in the form of pointers to the row data NOT OneDArray objects.

References dirac::TwoDArray< T >::m_array_of_rows.

## ◆ Resize()

template<class T >

void dirac::TwoDArray< T >::Resize | ( | const int | height,
|  | const int | width
| ) |  |

## Member Data Documentation

## ◆ m_array_of_rows

template<class T >

element_type* dirac::TwoDArray< T >::m_array_of_rows
| private

Referenced by dirac::TwoDArray< T >::CopyContents(), dirac::TwoDArray< T >::operator=(), dirac::TwoDArray< T >::operator[](), and dirac::TwoDArray< T >::TwoDArray().

## ◆ m_first_x

template<class T >

int dirac::TwoDArray< T >::m_first_x
| private

Referenced by dirac::TwoDArray< T >::FirstX(), dirac::TwoDArray< T >::operator=(), and dirac::TwoDArray< T >::TwoDArray().

## ◆ m_first_y

template<class T >

int dirac::TwoDArray< T >::m_first_y
| private

Referenced by dirac::TwoDArray< T >::FirstY(), dirac::TwoDArray< T >::operator=(), and dirac::TwoDArray< T >::TwoDArray().

## ◆ m_last_x

template<class T >

int dirac::TwoDArray< T >::m_last_x
| private

Referenced by dirac::TwoDArray< T >::LastX(), dirac::TwoDArray< T >::operator=(), and dirac::TwoDArray< T >::TwoDArray().

## ◆ m_last_y

template<class T >

int dirac::TwoDArray< T >::m_last_y
| private

Referenced by dirac::TwoDArray< T >::LastY(), dirac::TwoDArray< T >::operator=(), and dirac::TwoDArray< T >::TwoDArray().

## ◆ m_length_x

template<class T >

int dirac::TwoDArray< T >::m_length_x
| private

Referenced by dirac::TwoDArray< T >::CopyContents(), and dirac::TwoDArray< T >::LengthX().

## ◆ m_length_y

template<class T >

int dirac::TwoDArray< T >::m_length_y
| private

Referenced by dirac::TwoDArray< T >::CopyContents(), and dirac::TwoDArray< T >::LengthY().

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

- arrays.h

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.