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>

Inheritance diagram for dirac::OneDArray< T >:

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

◆ OneDArray() [1/4]

template<class T>
dirac::OneDArray< T >::OneDArray ( )

Default constructor produces an empty array.

References Init().

Referenced by OneDArray(), and operator=().

◆ OneDArray() [2/4]

template<class T>
dirac::OneDArray< T >::OneDArray ( const int len)

Length constructor produces a zero-based array.

References Init().

◆ OneDArray() [3/4]

template<class T>
dirac::OneDArray< T >::OneDArray ( const Range & r)

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

Parameters
ra range of indexing values.

References Init().

◆ ~OneDArray()

template<class T>
dirac::OneDArray< T >::~OneDArray ( )
inline

Destructor frees the data allocated in the constructors.

References FreePtr().

◆ OneDArray() [4/4]

template<class T>
dirac::OneDArray< T >::OneDArray ( const OneDArray< T > & cpy)

Copy constructor copies both data and metadata.

References Init(), m_first, m_last, m_length, m_ptr, and OneDArray().

Member Function Documentation

◆ First()

template<class T>
int dirac::OneDArray< T >::First ( ) const
inline

References m_first.

◆ FreePtr()

template<class T>
void dirac::OneDArray< T >::FreePtr ( )
private

References m_length, and m_ptr.

Referenced by operator=(), Resize(), and ~OneDArray().

◆ Init() [1/2]

template<class T>
void dirac::OneDArray< T >::Init ( const int len)
private

◆ Init() [2/2]

template<class T>
void dirac::OneDArray< T >::Init ( const Range & r)
private

◆ Last()

template<class T>
int dirac::OneDArray< T >::Last ( ) const
inline

References m_last.

◆ Length()

template<class T>
int dirac::OneDArray< T >::Length ( ) const
inline

References m_length.

◆ operator=()

template<class T>
OneDArray< T > & dirac::OneDArray< T >::operator= ( const OneDArray< T > & rhs)

Assignment= assigns both data and metadata.

References FreePtr(), Init(), m_first, m_last, m_length, m_ptr, and OneDArray().

◆ operator[]() [1/2]

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

References m_first, and m_ptr.

◆ operator[]() [2/2]

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

References m_first, and m_ptr.

◆ Resize()

template<class T>
void dirac::OneDArray< T >::Resize ( int l)

References FreePtr(), Init(), and m_length.

Member Data Documentation

◆ m_first

template<class T>
int dirac::OneDArray< T >::m_first
private

◆ m_last

template<class T>
int dirac::OneDArray< T >::m_last
private

Referenced by Init(), Last(), OneDArray(), and operator=().

◆ m_length

template<class T>
int dirac::OneDArray< T >::m_length
private

◆ m_ptr

template<class T>
T* dirac::OneDArray< T >::m_ptr
private

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

© 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.