40 #ifndef _DYNAMIC_ARRAY_H
41 #define _DYNAMIC_ARRAY_H
51 #if defined (_MSC_VER)
52 #pragma warning( push, 3 )
62 template <
class T,
bool TypeIsSimple = true>
75 if (!_objects || _size == 0)
83 typedef T ElementType;
120 void Count(
const unsigned int count)
138 inline unsigned int Size()
const {
return _size; }
143 void Size(
unsigned int newSize)
152 _objects =
new T[newSize];
153 DistiAssert(_objects);
156 memset(_objects,0,newSize*
sizeof(T));
162 if (newSize == _size)
165 newobjs =
new T[newSize];
166 DistiAssert(newobjs);
174 memcpy(newobjs,_objects,_size*
sizeof(T));
178 for(
unsigned int i=0; i < _size; i++)
180 newobjs[i] = _objects[i];
185 memset(newobjs+_size,0,(newSize-_size)*
sizeof(T));
194 memcpy(newobjs,_objects,newSize*
sizeof(T));
198 for(
unsigned int i=0; i < newSize; i++)
200 newobjs[i] = _objects[i];
249 for (
unsigned int i=_count-1; i > loc; i--)
251 _objects[i] = _objects[i-1];
316 for (
unsigned int j=index; j < (_count - 1u); j++)
318 _objects[j] = _objects[j+1u];
332 for (
unsigned int i=0;i <
_count; i++)
333 if (obj==_objects[i])
343 for (
unsigned int i=0; i <
Count(); i++)
357 memset(_objects,0,
sizeof(T) * _size);
375 DistiAssert(
int(index) >= 0);
384 else if (index >= _count)
389 return _objects[index];
403 for(
unsigned int i = 0; i <
Size(); i++)
407 _count = right.
Count();
418 #if defined (_MSC_VER)
419 #pragma warning( pop )
void ClearList(void)
Definition: dynamic_array.h:350
unsigned int Count() const
Definition: dynamic_array.h:133
Definition: dynamic_array.h:63
T & operator[](unsigned int index)
Definition: dynamic_array.h:373
int Position(const T &obj)
Definition: dynamic_array.h:330
void EmptyList(void)
Definition: dynamic_array.h:341
void InsertObjectAfter(const T &obj, unsigned int loc)
Definition: dynamic_array.h:285
unsigned int InsertObject(const T &obj)
Definition: dynamic_array.h:261
bool IsEmpty(void) const
Definition: dynamic_array.h:412
bool DeleteObjectAtIndex(unsigned int index)
Definition: dynamic_array.h:308
void InsertObject(const T &obj, unsigned int loc)
Definition: dynamic_array.h:231
A file for all GL Studio files to include.
void GrowArray(void)
Definition: dynamic_array.h:73
bool DeleteObject(const T &obj)
Definition: dynamic_array.h:294
void Count(const unsigned int count)
Definition: dynamic_array.h:120
~DynamicArray(void)
Definition: dynamic_array.h:109
unsigned int _count
Definition: dynamic_array.h:68
T * InternalArray(void)
Definition: dynamic_array.h:394
void PushObject(const T &obj)
Definition: dynamic_array.h:276
DynamicArray(int initialSize=0)
Definition: dynamic_array.h:88
void Size(unsigned int newSize)
Definition: dynamic_array.h:143
Contains the DistiAssert macro.
DynamicArray< T, TypeIsSimple > & operator=(const DynamicArray< T, TypeIsSimple > &right)
Definition: dynamic_array.h:400
unsigned int Size() const
Definition: dynamic_array.h:138
Definition: bmpimage.h:46
T * _objects
Definition: dynamic_array.h:69