Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

VM::NonResizeableArray< T, N > Struct Template Reference

Simple non-resizeable array for arbitrary types with default constructor. More...

#include <nrarray.h>

Collaboration diagram for VM::NonResizeableArray< T, N >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 NonResizeableArray ()
 Construct empty array; use alloc() to allocate the content.

 NonResizeableArray (N n)
 Construct array of specified size.

 NonResizeableArray (const NonResizeableArray &a)
 Copy array (content).

 ~NonResizeableArray ()
 Destroy (free) array.

NonResizeableArrayoperator= (const NonResizeableArray &a)
 Assign array by copying the content.

T & operator[] (N i)
 Index array; no range check.

const T & operator[] (N i) const
 Index array (const version); no range check.

n () const
 Get number of elements.

T * ptr ()
 Get the array base pointer. Be careful with that!

const T * ptr () const
 Get the array base pointer (const version). Be careful with that!

void alloc (N n, bool do_clear=1)
 Explicitly allocate elements.

void free ()
 Explicitly free array contents.

void clear ()
 Clear the array, i.e. re-initialize all elements.

void clear (N i)
 Clear specified element.

void SetAll (const T &v)

Private Member Functions

void _alloc ()
void _free ()
void _copy (const NonResizeableArray &a)

Private Attributes

T * array
size

Detailed Description

template<typename T, typename N = size_t>
struct VM::NonResizeableArray< T, N >

Simple non-resizeable array for arbitrary types with default constructor.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
Simple array class where the array gets allocated once with desired size and automatically freed upon destruction. Copy construction via array copying (not referencing). No resizing of arrays.

This class is C++-safe but that should not be used too much as it is inefficient.

Definition at line 47 of file nrarray.h.


Constructor & Destructor Documentation

template<typename T, typename N = size_t>
VM::NonResizeableArray< T, N >::NonResizeableArray  )  [inline]
 

Construct empty array; use alloc() to allocate the content.

Definition at line 61 of file nrarray.h.

template<typename T, typename N = size_t>
VM::NonResizeableArray< T, N >::NonResizeableArray n  )  [inline]
 

Construct array of specified size.

Definition at line 63 of file nrarray.h.

template<typename T, typename N = size_t>
VM::NonResizeableArray< T, N >::NonResizeableArray const NonResizeableArray< T, N > &  a  )  [inline]
 

Copy array (content).

Definition at line 65 of file nrarray.h.

template<typename T, typename N = size_t>
VM::NonResizeableArray< T, N >::~NonResizeableArray  )  [inline]
 

Destroy (free) array.

Definition at line 68 of file nrarray.h.


Member Function Documentation

template<typename T, typename N = size_t>
void VM::NonResizeableArray< T, N >::_alloc  )  [inline, private]
 

Definition at line 53 of file nrarray.h.

Referenced by VM::NonResizeableArray< VTableEntry, uint32 >::alloc(), VM::NonResizeableArray< VTableEntry, uint32 >::NonResizeableArray(), and VM::NonResizeableArray< VTableEntry, uint32 >::operator=().

template<typename T, typename N = size_t>
void VM::NonResizeableArray< T, N >::_copy const NonResizeableArray< T, N > &  a  )  [inline, private]
 

Definition at line 57 of file nrarray.h.

Referenced by VM::NonResizeableArray< VTableEntry, uint32 >::NonResizeableArray(), and VM::NonResizeableArray< VTableEntry, uint32 >::operator=().

template<typename T, typename N = size_t>
void VM::NonResizeableArray< T, N >::_free  )  [inline, private]
 

Definition at line 55 of file nrarray.h.

Referenced by VM::NonResizeableArray< VTableEntry, uint32 >::alloc(), VM::NonResizeableArray< VTableEntry, uint32 >::free(), VM::NonResizeableArray< VTableEntry, uint32 >::operator=(), and VM::NonResizeableArray< VTableEntry, uint32 >::~NonResizeableArray().

template<typename T, typename N = size_t>
void VM::NonResizeableArray< T, N >::alloc n,
bool  do_clear = 1
[inline]
 

Explicitly allocate elements.

Allocate n elements; in case the current size is not 0, it will NOT resize the array but free the old content and allocate new memory.

If do_clear is set, the array is guaranteed to be cleared afterwards (i.e. all elements newly initialized), otherwise this is only the case if the size was actually changed.

Definition at line 102 of file nrarray.h.

template<typename T, typename N = size_t>
void VM::NonResizeableArray< T, N >::clear i  )  [inline]
 

Clear specified element.

Definition at line 115 of file nrarray.h.

template<typename T, typename N = size_t>
void VM::NonResizeableArray< T, N >::clear  )  [inline]
 

Clear the array, i.e. re-initialize all elements.

Definition at line 112 of file nrarray.h.

Referenced by VM::NonResizeableArray< VTableEntry, uint32 >::alloc().

template<typename T, typename N = size_t>
void VM::NonResizeableArray< T, N >::free  )  [inline]
 

Explicitly free array contents.

Definition at line 109 of file nrarray.h.

template<typename T, typename N = size_t>
N VM::NonResizeableArray< T, N >::n  )  const [inline]
 

Get number of elements.

Definition at line 84 of file nrarray.h.

Referenced by VM::VMLinker::_MergeNamespaceInfo_Recursive().

template<typename T, typename N = size_t>
NonResizeableArray& VM::NonResizeableArray< T, N >::operator= const NonResizeableArray< T, N > &  a  )  [inline]
 

Assign array by copying the content.

Definition at line 72 of file nrarray.h.

template<typename T, typename N = size_t>
const T& VM::NonResizeableArray< T, N >::operator[] i  )  const [inline]
 

Index array (const version); no range check.

Definition at line 81 of file nrarray.h.

template<typename T, typename N = size_t>
T& VM::NonResizeableArray< T, N >::operator[] i  )  [inline]
 

Index array; no range check.

Definition at line 79 of file nrarray.h.

template<typename T, typename N = size_t>
const T* VM::NonResizeableArray< T, N >::ptr  )  const [inline]
 

Get the array base pointer (const version). Be careful with that!

Definition at line 89 of file nrarray.h.

template<typename T, typename N = size_t>
T* VM::NonResizeableArray< T, N >::ptr  )  [inline]
 

Get the array base pointer. Be careful with that!

Definition at line 87 of file nrarray.h.

template<typename T, typename N = size_t>
void VM::NonResizeableArray< T, N >::SetAll const T &  v  )  [inline]
 

Definition at line 119 of file nrarray.h.


Member Data Documentation

template<typename T, typename N = size_t>
T* VM::NonResizeableArray< T, N >::array [private]
 

Definition at line 50 of file nrarray.h.

Referenced by VM::NonResizeableArray< VTableEntry, uint32 >::_copy().

template<typename T, typename N = size_t>
N VM::NonResizeableArray< T, N >::size [private]
 

Definition at line 51 of file nrarray.h.

Referenced by VM::NonResizeableArray< VTableEntry, uint32 >::operator=().


The documentation for this struct was generated from the following file:
Generated on Sat Feb 19 22:36:19 2005 for Ray by doxygen 1.3.5