Template Dynamic array class that creates an array that can be used like a list or an array.
It grows and shrinks dynamically, while elements can be accessed via index. It only stores CSGObject pointers, which ARE automagically SG_REF'd/deleted.
Note that this array is generic, but only takes pointers to objects which implement the CSGObject interface, so only put these in here. T specifies the type of the pointers
Definition at line 32 of file DynamicObjectArray.h.
Public Member Functions | |
CDynamicObjectArray (int32_t p_resize_granularity=128) | |
virtual | ~CDynamicObjectArray () |
int32_t | set_granularity (int32_t g) |
int32_t | get_num_elements (void) const |
T * | get_element (int32_t index) const |
T * | get_element_safe (int32_t index) const |
bool | set_element (T *element, int32_t index) |
bool | insert_element (T *element, int32_t index) |
bool | append_element (T *element) |
void | push_back (T *element) |
void | pop_back (void) |
T * | back (void) const |
int32_t | find_element (T *element) const |
bool | delete_element (int32_t idx) |
void | clear_array () |
CDynamicObjectArray< T > & | operator= (CDynamicObjectArray< T > &orig) |
T ** | get_array () const |
void | shuffle () |
virtual const char * | get_name () const |
CDynamicObjectArray | ( | int32_t | p_resize_granularity = 128 |
) |
constructor
p_resize_granularity | resize granularity |
Definition at line 41 of file DynamicObjectArray.h.
virtual ~CDynamicObjectArray | ( | ) | [virtual] |
Definition at line 54 of file DynamicObjectArray.h.
bool append_element | ( | T * | element | ) |
append array element to the end of array
element | element to append |
Definition at line 146 of file DynamicObjectArray.h.
T* back | ( | void | ) | const |
STD VECTOR compatible. Return array element at the end of array.
Definition at line 184 of file DynamicObjectArray.h.
void clear_array | ( | void | ) |
clear the array (with zeros)
Definition at line 218 of file DynamicObjectArray.h.
bool delete_element | ( | int32_t | idx | ) |
delete array element at idx (does not call SG_FREE() or the like)
idx | index |
Definition at line 209 of file DynamicObjectArray.h.
int32_t find_element | ( | T * | element | ) | const |
find first occurence of array element and return its index or -1 if not available
element | element to search for |
Definition at line 198 of file DynamicObjectArray.h.
T** get_array | ( | void | ) | const |
Definition at line 244 of file DynamicObjectArray.h.
T* get_element | ( | int32_t | index | ) | const |
get array element at index
(does NOT do bounds checking)
index | index |
Definition at line 80 of file DynamicObjectArray.h.
T* get_element_safe | ( | int32_t | index | ) | const |
get array element at index
(does bounds checking)
index | index |
Definition at line 95 of file DynamicObjectArray.h.
virtual const char* get_name | ( | void | ) | const [virtual] |
int32_t get_num_elements | ( | void | ) | const |
get number of elements
Definition at line 68 of file DynamicObjectArray.h.
bool insert_element | ( | T * | element, | |
int32_t | index | |||
) |
insert array element at index
element | element to insert | |
index | index |
Definition at line 131 of file DynamicObjectArray.h.
CDynamicObjectArray<T>& operator= | ( | CDynamicObjectArray< T > & | orig | ) |
operator overload for array assignment
orig | original array |
Definition at line 229 of file DynamicObjectArray.h.
void pop_back | ( | void | ) |
STD VECTOR compatible. Delete array element at the end of array.
Definition at line 171 of file DynamicObjectArray.h.
void push_back | ( | T * | element | ) |
STD VECTOR compatible. Append array element to the end of array.
element | element to append |
Definition at line 161 of file DynamicObjectArray.h.
bool set_element | ( | T * | element, | |
int32_t | index | |||
) |
set array element at index
element | element to set | |
index | index |
Definition at line 109 of file DynamicObjectArray.h.
int32_t set_granularity | ( | int32_t | g | ) |
set the resize granularity
g | new granularity |
Definition at line 61 of file DynamicObjectArray.h.
void shuffle | ( | ) |
shuffles the array
Definition at line 247 of file DynamicObjectArray.h.