1 #ifndef _DYNAMIC_PTR_ARRAY_H
2 #define _DYNAMIC_PTR_ARRAY_H
71 assert(( _size > 0) && (NULL != _objects));
78 void Size(
unsigned int newSize)
83 newobjs =
new T[newSize];
87 memset(newobjs,0,newSize*
sizeof(T));
92 memcpy(newobjs,_objects,_size*
sizeof(T));
104 typedef T ElementType;
146 inline unsigned int Size()
const {
return _size; }
156 unsigned int newCount = _count+1;
159 if (newCount > _size)
171 assert(0 &&
"Array out of bounds");
175 for (
unsigned int i=_count-1; i > loc; i--)
176 _objects[i] = _objects[i-1];
188 if ((_count+1) > _size)
246 for (
unsigned int j=index; j < (_count - 1u); j++)
247 _objects[j] = _objects[j+1u];
268 delete _objects[index];
270 for (
unsigned int j=index; j < (_count - 1u); j++)
271 _objects[j] = _objects[j+1u];
285 for (
unsigned int i=0;i <
_count; i++)
286 if (obj==_objects[i])
311 void Swap(
unsigned int a,
unsigned int b)
315 _objects[a] = _objects[b];
324 for (
unsigned int i=0; i <
Count(); i++)
336 memset(_objects,0,
sizeof(T) * _size);
344 assert( (index >= 0) && (index < (
int)_count) && (index < (
int)_size)
345 &&
"Array out of bounds");
348 return _objects[index];
354 assert( (index >= 0) && (index < (
int)_count) && (index < (
int)_size)
355 &&
"Array out of bounds");
358 return _objects[index];
372 for(
unsigned int i = 0; i <
Size(); i++)
376 _count = right.
Count();
void Swap(unsigned int a, unsigned int b)
Definition: dynamic_ptr_array.h:311
A templated array of object pointers. The array dynamically resizes as needed.
Definition: dynamic_ptr_array.h:55
void InsertObject(const T &obj, unsigned int loc)
Definition: dynamic_ptr_array.h:154
unsigned int Size() const
Definition: dynamic_ptr_array.h:146
unsigned int _count
Definition: dynamic_ptr_array.h:60
This header defines a DDD_DEBUG only macro for facilitating evaluating class invariants in the Data D...
DynamicPtrArray(int initialSize=0)
Definition: dynamic_ptr_array.h:109
~DynamicPtrArray(void)
Definition: dynamic_ptr_array.h:130
bool RemoveAndDeallocateObjectAtIndex(unsigned int index)
Definition: dynamic_ptr_array.h:259
void Size(unsigned int newSize)
Definition: dynamic_ptr_array.h:78
void PushObject(const T &obj)
Definition: dynamic_ptr_array.h:203
void InsertObjectAfter(const T &obj, unsigned int loc)
Definition: dynamic_ptr_array.h:212
void GrowArray(void)
Definition: dynamic_ptr_array.h:64
T * InternalArray(void)
Definition: dynamic_ptr_array.h:363
int Position(const T &obj)
Definition: dynamic_ptr_array.h:283
bool RemoveAndDeallocate(T &obj)
Definition: dynamic_ptr_array.h:294
T * _objects
Definition: dynamic_ptr_array.h:61
unsigned int Count() const
Definition: dynamic_ptr_array.h:141
bool DeleteObjectAtIndex(unsigned int index)
Definition: dynamic_ptr_array.h:238
bool IsEmpty(void) const
Definition: dynamic_ptr_array.h:382
void ClearList(void)
Definition: dynamic_ptr_array.h:332
DynamicPtrArray< T > & operator=(const DynamicPtrArray< T > &right)
Definition: dynamic_ptr_array.h:369
unsigned int InsertObject(const T &obj)
Definition: dynamic_ptr_array.h:185
void EmptyList(void)
Definition: dynamic_ptr_array.h:322
Definition: AttributeChangedEmitter.h:46
T & operator[](int index)
Definition: dynamic_ptr_array.h:342
bool DeleteObject(const T &obj)
Definition: dynamic_ptr_array.h:222