#include <dynamic_array.h>
template<class T, bool TypeIsSimple = true>
class disti::DynamicArray< T, TypeIsSimple >
A templated array of objects. The array dynamically resizes as needed.
- Parameters
-
TypeIsSimple | set to true for types which can be initialized to all zero using memset. If T is a class with a default constructor, a working '=' operator, set TypeIsSimple to false. |
DynamicArray constructor
- Parameters
-
initialSize | The initial number of elements to be allocated for the array |
DynamicArray 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
void Count |
( |
const unsigned int |
count | ) |
|
|
inline |
Set the "Count" value for this array
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
-
obj | 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 | 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
-
obj | 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[] |
( |
unsigned int |
index | ) |
|
|
inline |
Overload of array operator to get element at desired index
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
-
obj | A pointer to the object to add |
unsigned int Size |
( |
| ) |
const |
|
inline |
Returns the current size of this dynamic array
- Returns
- The current size of the array (number of elements)
void Size |
( |
unsigned int |
newSize | ) |
|
|
inline |
Sets the array size to the new size given. Reallocates the array as needed
- Parameters
-
newSize | The new number of elements in the array |
Number of elements in the array
The documentation for this class was generated from the following file: