# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CObjectVector Class Template Reference

The purpose of this class is to copy most (but not all) of stl vector<> features, without some of the speed/memory problems involved: size of a vector<T> is 16 bytes typically. More...

#include <object_vector.h>

List of all members.

Public Methods

Object
 CObjectVector ()
 ~CObjectVector ()
 CObjectVector (const CObjectVector &vec)
 copy cons. More...

CObjectVector & operator= (const CObjectVector &vec)
 copy the array. More...

Allocation
void clear ()
 clear the array. More...

void resize (uint32 size)
 resize the array. More...

Accessor
uint32 size () const
 return size of the array (in number of elements). More...

T & operator[] (uint index) const
 Element accessor. More...

T * getPtr () const
 return a ptr on the first element of the array. More...

Tools
void copy (uint32 dstFirst, uint32 dstLast, const T *srcPtr)
 copy elements from an array ptr to this vector, beetween dstFirst element (included) and dstLast element (not included). More...

void fill (uint32 dstFirst, uint32 dstLast, const T &value)
 fill elements with a value, beetween dstFirst element (included) and dstLast element (not included). More...

void fill (const T &value)
 fill all elements with a value. More...

void serial (NLMISC::IStream &f)
 Serial this ObjectVector. More...


Private Methods

void myRealloc (uint32 size)
void destruct (uint32 i0, uint32 i1)
void construct (uint32 i0, uint32 i1)

Private Attributes

T * _Ptr
 Ptr on our array. More...

uint32 _Size
 size of the array, in number of elements. More...


Detailed Description

template<class T, bool EnableObjectBehavior = true>
class NLMISC::CObjectVector< T, EnableObjectBehavior >

The purpose of this class is to copy most (but not all) of stl vector<> features, without some of the speed/memory problems involved: size of a vector<T> is 16 bytes typically.

Object contructors, destructors, operator= are correctly called, unless EnableObjectBehavior template argument is set to false (default is true) In this case: ctor, dtor are not called, and operator=() use memcpy.

Of course some features are not implemented (for benefit of speed/memory):

  • no reserve() scheme
Also, for now, not all vector<> features are implemented (iterator, erase etc...).

Author:
Lionel Berenguier , Nevrax France
Date:
2001

Definition at line 71 of file object_vector.h.


Constructor & Destructor Documentation

template<class T, bool EnableObjectBehavior = true>
NLMISC::CObjectVector< T, EnableObjectBehavior >::CObjectVector   [inline]
 

Definition at line 77 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::CObjectVector, and NLMISC::CObjectVector< CVertex >::operator=.

template<class T, bool EnableObjectBehavior = true>
NLMISC::CObjectVector< T, EnableObjectBehavior >::~CObjectVector   [inline]
 

Definition at line 82 of file object_vector.h.

template<class T, bool EnableObjectBehavior = true>
NLMISC::CObjectVector< T, EnableObjectBehavior >::CObjectVector const CObjectVector< T, EnableObjectBehavior > &    vec [inline]
 

copy cons.

Exceptions:
EReallocationFailed  () if realloc fails.

Definition at line 89 of file object_vector.h.


Member Function Documentation

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::clear   [inline]
 

clear the array.

Definition at line 118 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::myRealloc, NLMISC::CObjectVector< CVertex >::resize, and NLMISC::CObjectVector< CVertex >::~CObjectVector.

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::construct uint32    i0,
uint32    i1
[inline, private]
 

Definition at line 346 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::resize.

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::copy uint32    dstFirst,
uint32    dstLast,
const T *    srcPtr
[inline]
 

copy elements from an array ptr to this vector, beetween dstFirst element (included) and dstLast element (not included).

nlassert if last is too big. copy(y, x, ...) where y>=x is valid, and nothing is copied.

Definition at line 191 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::operator=.

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::destruct uint32    i0,
uint32    i1
[inline, private]
 

Definition at line 332 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::clear, and NLMISC::CObjectVector< CVertex >::resize.

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::fill const T &    value [inline]
 

fill all elements with a value.

Definition at line 231 of file object_vector.h.

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::fill uint32    dstFirst,
uint32    dstLast,
const T &    value
[inline]
 

fill elements with a value, beetween dstFirst element (included) and dstLast element (not included).

Definition at line 216 of file object_vector.h.

template<class T, bool EnableObjectBehavior = true>
T* NLMISC::CObjectVector< T, EnableObjectBehavior >::getPtr   const [inline]
 

return a ptr on the first element of the array.

NULL if empty.

Definition at line 180 of file object_vector.h.

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::myRealloc uint32    size [inline, private]
 

Definition at line 313 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::resize.

template<class T, bool EnableObjectBehavior = true>
CObjectVector& NLMISC::CObjectVector< T, EnableObjectBehavior >::operator= const CObjectVector< T, EnableObjectBehavior > &    vec [inline]
 

copy the array.

Exceptions:
EReallocationFailed  () if realloc fails.

Definition at line 98 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::CObjectVector.

template<class T, bool EnableObjectBehavior = true>
T& NLMISC::CObjectVector< T, EnableObjectBehavior >::operator[] uint    index const [inline]
 

Element accessor.

no check is made on index. (No exception, no nlassert())

Definition at line 173 of file object_vector.h.

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::resize uint32    size [inline]
 

resize the array.

If reallocation occurs, ptr returned by getPtr() may not be the same. When reallocation occurs, memory is coped, but operator= are not called.

Exceptions:
EReallocationFailed  () if realloc fails.

Definition at line 131 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::operator=, and NLMISC::CObjectVector< CVertex >::serial.

template<class T, bool EnableObjectBehavior = true>
void NLMISC::CObjectVector< T, EnableObjectBehavior >::serial NLMISC::IStream   f [inline]
 

Serial this ObjectVector.

NB: actually, the serial of a vector<> and the serial of a CObjectVector is the same in the stream.

Definition at line 245 of file object_vector.h.

template<class T, bool EnableObjectBehavior = true>
uint32 NLMISC::CObjectVector< T, EnableObjectBehavior >::size   const [inline]
 

return size of the array (in number of elements).

Definition at line 169 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::myRealloc, NL3D::CSkeletonModelRenderObs::renderSkinList, NLMISC::CObjectVector< CVertex >::resize, and NLMISC::CObjectVector< CVertex >::serial.


Member Data Documentation

template<class T, bool EnableObjectBehavior = true>
T* NLMISC::CObjectVector::_Ptr [private]
 

Ptr on our array.

Definition at line 306 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::clear, NLMISC::CObjectVector< CVertex >::CObjectVector, NLMISC::CObjectVector< CVertex >::construct, NLMISC::CObjectVector< CVertex >::copy, NLMISC::CObjectVector< CVertex >::destruct, NLMISC::CObjectVector< CVertex >::fill, NLMISC::CObjectVector< CVertex >::getPtr, NLMISC::CObjectVector< CVertex >::myRealloc, NLMISC::CObjectVector< CVertex >::operator[], and NLMISC::CObjectVector< CVertex >::serial.

template<class T, bool EnableObjectBehavior = true>
uint32 NLMISC::CObjectVector::_Size [private]
 

size of the array, in number of elements.

Definition at line 308 of file object_vector.h.

Referenced by NLMISC::CObjectVector< CVertex >::clear, NLMISC::CObjectVector< CVertex >::CObjectVector, NLMISC::CObjectVector< CVertex >::copy, NLMISC::CObjectVector< CVertex >::fill, NLMISC::CObjectVector< CVertex >::operator=, NLMISC::CObjectVector< CVertex >::resize, and NLMISC::CObjectVector< CVertex >::size.


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