# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

# dirac::OneDArray< T > Class Template Reference

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

`#include <arrays.h>`

List of all members.

## Public Member Functions

- OneDArray ()
    Default constructor.
- OneDArray (const int len)
    'Length' constructor.
- OneDArray (const Range &r)
    Range constructor.
- ~OneDArray ()
    Destructor.
- OneDArray (const OneDArray< T > &cpy)
    Copy constructor.
- OneDArray< T > & operator= (const OneDArray< T > &rhs)
    Assignment=.
- void Resize (int l)
    Resize the array, throwing away the current data.
- T & operator[] (const int pos)
    Element access.
- const T & operator[] (const int pos) const
    Element access.
- int Length () const
    Returns the length of the array.
- int First () const
    Returns the index of the first element.
- int Last () const
    Returns the index of the last element.

## Private Member Functions

- void Init (const int len)
- void Init (const Range &r)
- void FreePtr ()

## Private Attributes

- int m_first
- int m_last
- int m_length
- T * m_ptr

## Detailed Description

### template<class T>
class dirac::OneDArray< T >

A template class for one-D arrays. Can be used wherever built-in arrays are used, and eliminates the need for explicit memory (de-)allocation. Also supports arrays not based at zero.

## Constructor & Destructor Documentation

template<class T >

dirac::OneDArray< T >::OneDArray | ( |  | ) | `[inline]`

Default constructor produces an empty array.

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

template<class T >

dirac::OneDArray< T >::OneDArray | ( | const int | len | ) | `[inline]`

Length constructor produces a zero-based array.

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

template<class T >

dirac::OneDArray< T >::OneDArray | ( | const Range & | r | ) | `[inline]`

Range constructor produces an array with values indexed within the range parameters.

Parameters:

  | r | a range of indexing values.

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

template<class T>

dirac::OneDArray< T >::~OneDArray | ( |  | ) | `[inline]`

Destructor frees the data allocated in the constructors.

template<class T>

dirac::OneDArray< T >::OneDArray | ( | const OneDArray< T > & | cpy | ) | `[inline]`

Copy constructor copies both data and metadata.

References dirac::OneDArray< T >::Init(), dirac::OneDArray< T >::m_first, dirac::OneDArray< T >::m_last, dirac::OneDArray< T >::m_length, and dirac::OneDArray< T >::m_ptr.

## Member Function Documentation

template<class T>

int dirac::OneDArray< T >::First | ( |  | ) | const`[inline]`

template<class T >

void dirac::OneDArray< T >::FreePtr | ( |  | ) | `[inline, private]`

References dirac::OneDArray< T >::m_length, and dirac::OneDArray< T >::m_ptr.

Referenced by dirac::OneDArray< T >::operator=(), dirac::OneDArray< T >::Resize(), and dirac::OneDArray< ImageCoords >::~OneDArray().

template<class T >

void dirac::OneDArray< T >::Init | ( | const Range & | r | ) | `[inline, private]`

References dirac::Range::First(), dirac::Range::Last(), dirac::OneDArray< T >::m_first, dirac::OneDArray< T >::m_last, dirac::OneDArray< T >::m_length, and dirac::OneDArray< T >::m_ptr.

template<class T >

void dirac::OneDArray< T >::Init | ( | const int | len | ) | `[inline, private]`

Referenced by dirac::OneDArray< T >::OneDArray(), dirac::OneDArray< T >::operator=(), and dirac::OneDArray< T >::Resize().

template<class T>

int dirac::OneDArray< T >::Last | ( |  | ) | const`[inline]`

template<class T>

int dirac::OneDArray< T >::Length | ( |  | ) | const`[inline]`

template<class T>

OneDArray< T > & dirac::OneDArray< T >::operator= | ( | const OneDArray< T > & | rhs | ) | `[inline]`

Assignment= assigns both data and metadata.

References dirac::OneDArray< T >::FreePtr(), dirac::OneDArray< T >::Init(), dirac::OneDArray< T >::m_first, dirac::OneDArray< T >::m_last, dirac::OneDArray< T >::m_length, and dirac::OneDArray< T >::m_ptr.

template<class T>

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

template<class T>

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

template<class T >

void dirac::OneDArray< T >::Resize | ( | int | l | ) | `[inline]`

References dirac::OneDArray< T >::FreePtr(), dirac::OneDArray< T >::Init(), and dirac::OneDArray< T >::m_length.

## Member Data Documentation

template<class T>

int dirac::OneDArray< T >::m_first`[private]`

Referenced by dirac::OneDArray< ImageCoords >::First(), dirac::OneDArray< T >::Init(), dirac::OneDArray< T >::OneDArray(), dirac::OneDArray< T >::operator=(), and dirac::OneDArray< ImageCoords >::operator[]().

template<class T>

int dirac::OneDArray< T >::m_last`[private]`

Referenced by dirac::OneDArray< T >::Init(), dirac::OneDArray< ImageCoords >::Last(), dirac::OneDArray< T >::OneDArray(), and dirac::OneDArray< T >::operator=().

template<class T>

int dirac::OneDArray< T >::m_length`[private]`

Referenced by dirac::OneDArray< T >::FreePtr(), dirac::OneDArray< T >::Init(), dirac::OneDArray< ImageCoords >::Length(), dirac::OneDArray< T >::OneDArray(), dirac::OneDArray< T >::operator=(), and dirac::OneDArray< T >::Resize().

template<class T>

T* dirac::OneDArray< T >::m_ptr`[private]`

Referenced by dirac::OneDArray< T >::FreePtr(), dirac::OneDArray< T >::Init(), dirac::OneDArray< T >::OneDArray(), dirac::OneDArray< T >::operator=(), and dirac::OneDArray< ImageCoords >::operator[]().

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.