vdk 2.4.0
Public Member Functions | Private Member Functions | List of all members
VDKArray< T > Class Template Reference

provides a templatized array More...

#include <vdkarray.h>

Inheritance diagram for VDKArray< T >:
Inheritance graph
[legend]

Public Member Functions

 VDKArray (int n=0)
 
 VDKArray (const VDKArray &)
 
VDKArrayoperator= (const VDKArray &)
 
virtual ~VDKArray ()
 
int size ()
 
void resize (int)
 
T & operator[] (int ndx)
 
VDKArray< T > & Heapsort ()
 
virtual int operator== (VDKArray< T > &m)
 

Private Member Functions

T & At (int ndx)
 

Detailed Description

template<class T>
class VDKArray< T >

provides a templatized array

OVERVIEW
VDKArray<T> class implements a value semantic, all managed objects are copied from original values. An array can contains type<T> objects, can resize himself to accomodate others objects, however resizing operations must be explicit. A generic type<T> must provide consistent:
  • T() default constructor
  • T(T& t) copy initializer
  • =(T& t) assignement operator in order to assure correct array deep-copying
Relational operators
A generic type<T> should provide also:
  • int operator==(T& t) equality operator
  • int operator<(T& t) disequality operator in order to correctly use heapsort routine.
CONSIDERATIONS
Arrays are bounds checked, try to access an element out of bounds will cause an assert()-call failure and abnormal program termination. I recommend to use typedef to consistently declare a type<T> Array:
typedef Array<someClass> SomeClassArray;
DEBUGGING
NO_DEBUG directive will avoid any bound checking
REFERENCE
U. Breymann et al. "Composite templates and inheritance" C++ Report, Vol.7, nr. 2, pp. 33-39, 1995

Constructor & Destructor Documentation

◆ VDKArray() [1/2]

template<class T >
VDKArray< T >::VDKArray ( int  n = 0)
inline

Constructor.

Parameters
narray length

◆ VDKArray() [2/2]

template<class T >
VDKArray< T >::VDKArray ( const VDKArray< T > &  v)

Copy initializer

◆ ~VDKArray()

template<class T >
virtual VDKArray< T >::~VDKArray ( )
inlinevirtual

Destructor

Member Function Documentation

◆ At()

template<class T >
T & VDKArray< T >::At ( int  ndx)
inlineprivate

/internal

◆ Heapsort()

template<class T >
VDKArray< T > & VDKArray< T >::Heapsort

Sorts array on place in n*log(n) time.

Reference
W.H.Press et al. "Numerical recipes in C" 2nd edition Cambridge University Press, 1992

◆ operator=()

template<class T >
VDKArray< T > & VDKArray< T >::operator= ( const VDKArray< T > &  v)

Assignement

◆ operator==()

template<class T >
int VDKArray< T >::operator== ( VDKArray< T > &  m)
virtual

equality operator

◆ operator[]()

template<class T >
T & VDKArray< T >::operator[] ( int  ndx)
inline

Access operator

tip
can be used in both left or rigth side of an expression
typedef<int> IntArray;
IntArray integers(10);
integers[0] = 6;
int i = integers[0];

◆ resize()

template<class T >
void VDKArray< T >::resize ( int  ns)

Resize array

◆ size()

template<class T >
int VDKArray< T >::size ( )
inline

Returns array size


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