40 #ifndef _DYNAMIC_ARRAY_H
41 #define _DYNAMIC_ARRAY_H
50 #if defined( _MSC_VER )
51 # pragma warning( push, 3 )
61 template<
class T,
bool TypeIsSimple = true>
72 if( !_objects || _size == 0 )
79 typedef T ElementType;
115 void Count(
const unsigned int count )
133 inline unsigned int Size()
const {
return _size; }
138 void Size(
unsigned int newSize )
147 _objects =
new T[ newSize ];
148 DistiAssert( _objects );
151 memset( _objects, 0, newSize *
sizeof( T ) );
157 if( newSize == _size )
160 newobjs =
new T[ newSize ];
161 DistiAssert( newobjs );
163 if( newSize > _size )
169 memcpy( newobjs, _objects, _size *
sizeof( T ) );
173 for(
unsigned int i = 0; i < _size; i++ )
175 newobjs[ i ] = _objects[ i ];
180 memset( newobjs + _size, 0, ( newSize - _size ) *
sizeof( T ) );
188 memcpy( newobjs, _objects, newSize *
sizeof( T ) );
192 for(
unsigned int i = 0; i < newSize; i++ )
194 newobjs[ i ] = _objects[ i ];
243 for(
unsigned int i = _count - 1; i > loc; i-- )
245 _objects[ i ] = _objects[ i - 1 ];
248 _objects[ loc ] = obj;
304 if( index >= _count )
310 for(
unsigned int j = index; j < ( _count - 1u ); j++ )
312 _objects[ j ] = _objects[ j + 1u ];
326 for(
unsigned int i = 0; i <
_count; i++ )
327 if( obj == _objects[ i ] )
337 for(
unsigned int i = 0; i <
Count(); i++ )
338 delete _objects[ i ];
351 memset( _objects, 0,
sizeof( T ) * _size );
369 DistiAssert(
int( index ) >= 0 );
378 else if( index >= _count )
383 return _objects[ index ];
397 for(
unsigned int i = 0; i <
Size(); i++ )
399 _objects[ i ] = right.
_objects[ i ];
401 _count = right.
Count();
408 return ( _count == 0 );
412 #if defined( _MSC_VER )
413 # pragma warning( pop )
void ClearList(void)
Definition: dynamic_array.h:344
DynamicArray< T, TypeIsSimple > & operator=(const DynamicArray< T, TypeIsSimple > &right)
Definition: dynamic_array.h:394
unsigned int Count() const
Definition: dynamic_array.h:128
Definition: dynamic_array.h:62
T & operator[](unsigned int index)
Definition: dynamic_array.h:367
int Position(const T &obj)
Definition: dynamic_array.h:324
void EmptyList(void)
Definition: dynamic_array.h:335
void InsertObjectAfter(const T &obj, unsigned int loc)
Definition: dynamic_array.h:279
unsigned int InsertObject(const T &obj)
Definition: dynamic_array.h:255
bool IsEmpty(void) const
Definition: dynamic_array.h:406
bool DeleteObjectAtIndex(unsigned int index)
Definition: dynamic_array.h:302
void InsertObject(const T &obj, unsigned int loc)
Definition: dynamic_array.h:225
A file for all GL Studio files to include.
void GrowArray(void)
Definition: dynamic_array.h:70
bool DeleteObject(const T &obj)
Definition: dynamic_array.h:288
void Count(const unsigned int count)
Definition: dynamic_array.h:115
~DynamicArray(void)
Definition: dynamic_array.h:105
unsigned int _count
Definition: dynamic_array.h:66
T * InternalArray(void)
Definition: dynamic_array.h:388
void PushObject(const T &obj)
Definition: dynamic_array.h:270
DynamicArray(int initialSize=0)
Definition: dynamic_array.h:84
void Size(unsigned int newSize)
Definition: dynamic_array.h:138
Contains the DistiAssert macro.
unsigned int Size() const
Definition: dynamic_array.h:133
Definition: bmpimage.h:46
T * _objects
Definition: dynamic_array.h:67