#include <object_vector.h>
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):
Also, for now, not all vector<> features are implemented (iterator, erase etc...).
Nevrax France
Definition at line 77 of file object_vector.h.
Public Member Functions | |
Allocation | |
void | clear () |
void | resize (uint32 s) |
Object | |
CObjectVector (const CObjectVector &vec) | |
CObjectVector () | |
CObjectVector & | operator= (const CObjectVector &vec) |
~CObjectVector () | |
Tools | |
void | copy (uint32 dstFirst, uint32 dstLast, const T *srcPtr) |
void | fill (const T &value) |
void | fill (uint32 dstFirst, uint32 dstLast, const T &value) |
void | serial (NLMISC::IStream &f) |
Accessor | |
bool | empty () const |
T * | getPtr () const |
T & | operator[] (uint index) const |
uint32 | size () const |
Private Member Functions | |
void | construct (uint32 i0, uint32 i1) |
void | destruct (uint32 i0, uint32 i1) |
void | myRealloc (uint32 s) |
Private Attributes | |
T * | _Ptr |
Ptr on our array. | |
uint32 | _Size |
size of the array, in number of elements. |
|
copy cons.
Definition at line 83 of file object_vector.h.
|
|
copy cons.
Definition at line 88 of file object_vector.h.
00089 { 00090 clear(); 00091 } |
|
copy cons.
Definition at line 95 of file object_vector.h.
|
|
clear the array. Definition at line 124 of file object_vector.h. Referenced by NLMISC::CObjectVector< sint8, false >::myRealloc(), NLMISC::CObjectVector< sint8, false >::resize(), NL3D::CSkeletonModel::updateSkinRenderLists(), and NLMISC::CObjectVector< sint8, false >::~CObjectVector().
|
|
Definition at line 382 of file object_vector.h. Referenced by NLMISC::CObjectVector< sint8, false >::resize().
00383 { 00384 // don't do it if elements don't need it. 00385 if(!EnableObjectBehavior) 00386 return; 00387 // for all elements 00388 for(uint i=i0;i<i1;i++) 00389 { 00390 // Must do a placement new 00391 #undef new 00392 // call ctor. 00393 new (_Ptr+i) T; 00394 // Must do a placement new 00395 #define new NL_NEW 00396 } 00397 } |
|
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 206 of file object_vector.h. Referenced by NLMISC::CObjectVector< sint8, false >::operator=().
00207 { 00208 // test if something to copy. 00209 if(dstFirst>=dstLast) 00210 return; 00211 nlassert(dstLast<=_Size); 00212 // if not object elements 00213 if(!EnableObjectBehavior) 00214 { 00215 // just memcpy 00216 memcpy(_Ptr+dstFirst, srcPtr, (dstLast-dstFirst)*sizeof(T)); 00217 } 00218 else 00219 { 00220 // call ope= for all elements. 00221 for(uint i=dstFirst; i<dstLast; i++, srcPtr++) 00222 { 00223 _Ptr[i]= *srcPtr; 00224 } 00225 } 00226 } |
|
Definition at line 368 of file object_vector.h. Referenced by NLMISC::CObjectVector< sint8, false >::clear(), and NLMISC::CObjectVector< sint8, false >::resize().
|
|
return true if the container is empty Definition at line 180 of file object_vector.h.
00180 {return _Size==0;} |
|
fill all elements with a value Definition at line 246 of file object_vector.h.
|
|
fill elements with a value, beetween dstFirst element (included) and dstLast element (not included). Definition at line 231 of file object_vector.h.
|
|
return a ptr on the first element of the array. NULL if empty. Definition at line 195 of file object_vector.h. Referenced by NL3D::CMeshMorpher::updateRawSkin().
00195 {return _Ptr;} |
|
Definition at line 328 of file object_vector.h. Referenced by NLMISC::CObjectVector< sint8, false >::resize().
00329 { 00330 #ifndef NL_OV_USE_NEW_ALLOCATOR 00331 // try to realloc the array. 00332 T *newPtr= (T*)realloc(_Ptr, s*sizeof(T)); 00333 #else // NL_OV_USE_NEW_ALLOCATOR 00334 uint allocSize= s*sizeof(T); 00335 T *newPtr= NULL; 00336 if (!_Ptr || (allocSize > _Size*sizeof(T))) 00337 { 00338 // Reallocate 00339 char *newblock = new char[allocSize]; 00340 if (_Ptr) 00341 { 00342 memcpy (newblock, _Ptr, _Size*sizeof(T)); 00343 delete [] (char*)_Ptr; 00344 } 00345 newPtr = (T*)newblock; 00346 } 00347 else 00348 { 00349 // Old block is big enough 00350 newPtr = _Ptr; 00351 } 00352 #endif // NL_OV_USE_NEW_ALLOCATOR 00353 // if realloc failure 00354 if(newPtr==NULL) 00355 { 00356 // leave the array in a clean state. 00357 clear(); 00358 // exception. 00359 throw EReallocationFailed(); 00360 } 00361 else 00362 { 00363 _Ptr= newPtr; 00364 } 00365 } |
|
copy the array.
Definition at line 104 of file object_vector.h. Referenced by NLMISC::CObjectVector< sint8, false >::CObjectVector().
|
|
Element accessor. no check is made on index. (No exception, no nlassert()) Definition at line 188 of file object_vector.h.
|
|
|
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 260 of file object_vector.h.
00261 { 00262 // Open a node header 00263 f.xmlPushBegin ("VECTOR"); 00264 00265 // Attrib size 00266 f.xmlSetAttrib ("size"); 00267 00268 sint32 len=0; 00269 if(f.isReading()) 00270 { 00271 f.serial(len); 00272 00273 // Open a node header 00274 f.xmlPushEnd (); 00275 00276 // special version for vector: adjut good size. 00277 contReset(*this); 00278 resize (len); 00279 00280 // Read the vector 00281 for(sint i=0;i<len;i++) 00282 { 00283 f.xmlPush ("ELM"); 00284 00285 f.serial(_Ptr[i]); 00286 00287 f.xmlPop (); 00288 } 00289 } 00290 else 00291 { 00292 len= size(); 00293 f.serial(len); 00294 00295 // Close the node header 00296 f.xmlPushEnd (); 00297 00298 // Write the vector 00299 for(sint i=0;i<len;i++) 00300 { 00301 f.xmlPush ("ELM"); 00302 00303 f.serial(_Ptr[i]); 00304 00305 f.xmlPop (); 00306 } 00307 } 00308 00309 // Close the node 00310 f.xmlPop (); 00311 } |
|
return size of the array (in number of elements) Definition at line 184 of file object_vector.h. Referenced by NLMISC::CBitmap::decompressDXT1(), NLMISC::CBitmap::decompressDXT3(), NLMISC::CBitmap::decompressDXT5(), NL3D::CSkeletonModel::renderShadowSkins(), NL3D::CSkeletonModel::renderSkinList(), NLMISC::CObjectVector< sint8, false >::serial(), and NL3D::CSkeletonModel::traverseAnimDetail().
00184 {return _Size;} |
|
Ptr on our array.
Definition at line 321 of file object_vector.h. Referenced by NLMISC::CObjectVector< sint8, false >::operator=(). |
|
size of the array, in number of elements.
Definition at line 323 of file object_vector.h. Referenced by NLMISC::CObjectVector< sint8, false >::operator=(). |