vdk 2.4.0
Public Member Functions | Private Member Functions
VDKArray< T > Class Template Reference

provides a templatized array More...

#include <vdkarray.h>

Inheritance diagram for VDKArray< T >:
Tuple VDKTreeViewModelTuple

List of all members.

Public Member Functions

Private Member Functions


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

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

Constructor.

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

Copy initializer

template<class T>
virtual VDKArray< T >::~VDKArray ( ) [inline, virtual]

Destructor


Member Function Documentation

template<class T>
T& VDKArray< T >::At ( int  ndx) [inline, private]

/internal

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
template<class T >
VDKArray< T > & VDKArray< T >::operator= ( const VDKArray< T > &  v)

Assignement

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

equality 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];
template<class T >
void VDKArray< T >::resize ( int  ns)

Resize array

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

Returns array size


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