A templated array of object pointers. The array dynamically resizes as needed.
More...
#include <dynamic_ptr_array.h>
template<class T>
class disti::DynamicPtrArray< T >
A templated array of object pointers. The array dynamically resizes as needed.
DynamicPtrArray constructor
- Parameters
-
The | initial number of elements to be allocated for the array |
DynamicPtrArray destructor. Clears the array but does not delete the objects being pointed to by the array
Clears the list so Count() is zero. Does not attempt to delete the objects data
unsigned int Count |
( |
| ) |
const |
|
inline |
Returns the number of elements used of this dynamic array
- Returns
- The number of elements used of the array (number of elements)
bool DeleteObject |
( |
const T & |
obj | ) |
|
|
inline |
Deletes the specified object from the list. Does not free it
- Parameters
-
A | pointer to the object to delete |
- Returns
- true if object was found and deleted else false
bool DeleteObjectAtIndex |
( |
unsigned int |
index | ) |
|
|
inline |
Deletes the object at the specified index. Does not free it
- Parameters
-
Index | of the object to delete |
- Returns
- true if object was found and deleted else false
Empties the list, calling delete on all of its elements This method is intended for pointer data types only.
Dynamic array is an array of objects Grow the array. If nothing has been allocated yet, set the size to 2 elements. Otherwise double the array size.
void InsertObject |
( |
const T & |
obj, |
|
|
unsigned int |
loc |
|
) |
| |
|
inline |
Attempts to insert the object into the list at the specified location. If the specified location is beyond the array bounds, the object is inserted at the next position in the array.
- Parameters
-
obj | The object to insert |
loc | The index location to insert into |
unsigned int InsertObject |
( |
const T & |
obj | ) |
|
|
inline |
Adds the specified object into the list, at the end of the list
- Parameters
-
A | pointer to the object to add |
- Returns
- Where the object was inserted
void InsertObjectAfter |
( |
const T & |
obj, |
|
|
unsigned int |
loc |
|
) |
| |
|
inline |
Insert the object into the list at the specified location
- Parameters
-
obj | The object to insert |
loc | The index location to insert into |
T* InternalArray |
( |
void |
| ) |
|
|
inline |
Return the internal array pointer If you call any other methods on this object it invalidates the pointer.
bool IsEmpty |
( |
void |
| ) |
const |
|
inline |
- Returns
- true if the list is empty
Overload the assignment operator to create a duplicate of the righthand operand
T& operator[] |
( |
int |
index | ) |
|
|
inline |
Overload of array operator to get element at desired index
const T& operator[] |
( |
int |
index | ) |
const |
|
inline |
Overload of array operator to get element at desired index - const safe version
int Position |
( |
const T & |
obj | ) |
|
|
inline |
Get the index position of the specified object in the list
- Parameters
-
- Returns
- The index of the object in the list, -1 if it isn't in the list
void PushObject |
( |
const T & |
obj | ) |
|
|
inline |
Adds the specified object into the list, at the head of the list Treats the list like a stack, hence the name Push
- Parameters
-
A | pointer to the object to add |
bool RemoveAndDeallocate |
( |
T & |
obj | ) |
|
|
inline |
Remove the specified object from the array and then call delete on it
- Parameters
-
obj | The pointer to the object to remove |
bool RemoveAndDeallocateObjectAtIndex |
( |
unsigned int |
index | ) |
|
|
inline |
Deletes the object at the specified index and frees it
- Parameters
-
Index | of the object to delete |
- Returns
- true if object was found and deleted else false
void Size |
( |
unsigned int |
newSize | ) |
|
|
inlineprotected |
Grows the array size to the new size given. Reallocates the array as needed. Will NOT ever shrink the array size.
- Parameters
-
newSize | The new number of elements in the array |
unsigned int Size |
( |
| ) |
const |
|
inline |
Returns the current size of this dynamic array
- Returns
- The current size of the array (number of elements)
void Swap |
( |
unsigned int |
a, |
|
|
unsigned int |
b |
|
) |
| |
|
inline |
Swap the objects at index a and b
- Parameters
-
a | Index of first object |
b | Index of second object |
Number of elements in the array
The documentation for this class was generated from the following file: