Main Page   Class Hierarchy   Compound List   File List   Compound Members  

PackArray Class Template Reference

Packed array/vector; saves space and is fast. More...

#include <mpackarray.h>

Inheritance diagram for PackArray::

Object LinkNode::NodeLinkArray List of all members.

Public Methods

 PackArray ()
 PackArray (int siz)
 PackArray (const PackArray &orig)
void make (int siz)
 ~PackArray ()
void shallowCopy (const PackArray &orig)
void destroy ()
void empty ()
const TYPE& operator[] (int i) const
TYPE& operator[] (int i)
TYPE& operator= (const PackArray &other)
void resize (int newsize)
virtual void check () const

Public Attributes

TYPE* data
int size

Detailed Description

template<class TYPE> class PackArray

Packed array/vector; saves space and is fast.

Especially useful with the primitive types such as int or float. 0-based indexing.

NULL objects are not possible like in Array. Nor is this container as dynamic as Array is.

Definition at line 25 of file mpackarray.h.


Constructor & Destructor Documentation

PackArray ( int siz ) [inline]
 

Creates an packed array with the given size.

Definition at line 39 of file mpackarray.h.

PackArray ( const PackArray<TYPE> & orig ) [inline]
 

Copy constructor uses operator= to copy the contained items.

Remember to define the operator= for the object class, as the default operator= does only a shallow copy.

Definition at line 49 of file mpackarray.h.


Member Function Documentation

void check ( ) const [inline, virtual]
 

Implementation for Object.

Reimplemented from Object.

Definition at line 181 of file mpackarray.h.

void destroy ( ) [inline]
 

Empties the array.

Definition at line 79 of file mpackarray.h.

Referenced by empty(), make(), operator=(), and resize().

void empty ( ) [inline]
 

Empties the array.

Alias for destroy().

Definition at line 86 of file mpackarray.h.

void make ( int siz ) [inline]
 

Creates or recreates the array with the given size.

Definition at line 57 of file mpackarray.h.

Referenced by PackArray(), and shallowCopy().

TYPE & operator= ( const PackArray<TYPE> & other ) [inline]
 

Standard copy operator.

Remember to define the operator= for the object class, as the default operator= does only a shallow copy.

Definition at line 113 of file mpackarray.h.

TYPE & operator[] ( int i ) [inline]
 

Returns reference to i:th item in the array.

Non-const version.

Definition at line 102 of file mpackarray.h.

const TYPE & operator[] ( int i ) const [inline]
 

Returns reference to i:th item in the array.

Const version.

Definition at line 93 of file mpackarray.h.

void resize ( int newsize ) [inline]
 

Changes size of the array.

Definition at line 140 of file mpackarray.h.

void shallowCopy ( const PackArray<TYPE> & orig ) [inline]
 

Very quick copy operator.

Definition at line 72 of file mpackarray.h.


Member Data Documentation

TYPE * data
 

The items as a C-array.

Definition at line 28 of file mpackarray.h.

int size
 

Length of the array.

Definition at line 31 of file mpackarray.h.


The documentation for this class was generated from the following file:
Generated at Tue Dec 4 19:53:31 2001 for MagiC++ by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001