Created by the British Broadcasting Corporation.
A template class for one-dimensional arrays. More...
#include <arrays.h>
Public Member Functions | |
OneDArray () | |
Default constructor. More... | |
OneDArray (const int len) | |
'Length' constructor. More... | |
OneDArray (const Range &r) | |
Range constructor. More... | |
~OneDArray () | |
Destructor. More... | |
OneDArray (const OneDArray< T > &cpy) | |
Copy constructor. More... | |
OneDArray< T > & | operator= (const OneDArray< T > &rhs) |
Assignment=. More... | |
void | Resize (int l) |
Resize the array, throwing away the current data. More... | |
T & | operator[] (const int pos) |
Element access. More... | |
const T & | operator[] (const int pos) const |
Element access. More... | |
int | Length () const |
Returns the length of the array. More... | |
int | First () const |
Returns the index of the first element. More... | |
int | Last () const |
Returns the index of the last element. More... | |
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 |
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.
dirac::OneDArray< T >::OneDArray |
Default constructor produces an empty array.
dirac::OneDArray< T >::OneDArray | ( | const int | len | ) |
Length constructor produces a zero-based array.
dirac::OneDArray< T >::OneDArray | ( | const Range & | r | ) |
Range constructor produces an array with values indexed within the range parameters.
r | a range of indexing values. |
|
inline |
Destructor frees the data allocated in the constructors.
References dirac::OneDArray< T >::FreePtr().
dirac::OneDArray< T >::OneDArray | ( | const OneDArray< T > & | cpy | ) |
Copy constructor copies both data and metadata.
References dirac::OneDArray< T >::m_first, dirac::OneDArray< T >::m_last, and dirac::OneDArray< T >::m_ptr.
|
inline |
References dirac::OneDArray< T >::m_first.
|
private |
Referenced by dirac::OneDArray< T >::~OneDArray().
|
private |
|
private |
References dirac::Range::First(), and dirac::Range::Last().
|
inline |
References dirac::OneDArray< T >::m_last.
|
inline |
References dirac::OneDArray< T >::m_length.
OneDArray< T > & dirac::OneDArray< T >::operator= | ( | const OneDArray< T > & | rhs | ) |
Assignment= assigns both data and metadata.
References dirac::OneDArray< T >::m_first, dirac::OneDArray< T >::m_last, dirac::OneDArray< T >::m_length, and dirac::OneDArray< T >::m_ptr.
|
inline |
References dirac::OneDArray< T >::m_first, and dirac::OneDArray< T >::m_ptr.
|
inline |
References dirac::OneDArray< T >::m_first, and dirac::OneDArray< T >::m_ptr.
void dirac::OneDArray< T >::Resize | ( | int | l | ) |
|
private |
|
private |
|
private |
Referenced by dirac::OneDArray< T >::Length(), and dirac::OneDArray< T >::operator=().
|
private |
© 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.