|
SHOGUN
v1.1.0
|
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 is performance tuned for simple types like float etc. and for hi-level objects only stores pointers, which are not automagically SG_REF'd/deleted.
Definition at line 28 of file DynamicArray.h.

Public Member Functions | |
| CDynamicArray (int32_t p_resize_granularity=128) | |
| virtual | ~CDynamicArray () |
| int32_t | set_granularity (int32_t g) |
| int32_t | get_array_size () |
| int32_t | get_num_elements () 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 () |
| T | back () |
| int32_t | find_element (T element) |
| bool | delete_element (int32_t idx) |
| bool | resize_array (int32_t n) |
| T * | get_array () const |
| void | set_array (T *p_array, int32_t p_num_elements, int32_t array_size) |
| void | clear_array () |
| T | operator[] (int32_t index) const |
| CDynamicArray< T > & | operator= (CDynamicArray< T > &orig) |
| void | shuffle () |
| virtual const char * | get_name () const |
Public Member Functions inherited from CSGObject | |
| CSGObject () | |
| CSGObject (const CSGObject &orig) | |
| virtual | ~CSGObject () |
| virtual bool | is_generic (EPrimitiveType *generic) const |
| template<class T > | |
| void | set_generic () |
| void | unset_generic () |
| virtual void | print_serializable (const char *prefix="") |
| virtual bool | save_serializable (CSerializableFile *file, const char *prefix="") |
| virtual bool | load_serializable (CSerializableFile *file, const char *prefix="") |
| void | set_global_io (SGIO *io) |
| SGIO * | get_global_io () |
| void | set_global_parallel (Parallel *parallel) |
| Parallel * | get_global_parallel () |
| void | set_global_version (Version *version) |
| Version * | get_global_version () |
| SGVector< char * > | get_modelsel_names () |
| char * | get_modsel_param_descr (const char *param_name) |
| index_t | get_modsel_param_index (const char *param_name) |
Protected Attributes | |
| DynArray< T > | m_array |
Additional Inherited Members | |
Public Attributes inherited from CSGObject | |
| SGIO * | io |
| Parallel * | parallel |
| Version * | version |
| Parameter * | m_parameters |
| Parameter * | m_model_selection_parameters |
Protected Member Functions inherited from CSGObject | |
| virtual void | load_serializable_pre () throw (ShogunException) |
| virtual void | load_serializable_post () throw (ShogunException) |
| virtual void | save_serializable_pre () throw (ShogunException) |
| virtual void | save_serializable_post () throw (ShogunException) |
| CDynamicArray | ( | int32_t | p_resize_granularity = 128 | ) |
constructor
| p_resize_granularity | resize granularity |
Definition at line 35 of file DynamicArray.h.
|
virtual |
Definition at line 51 of file DynamicArray.h.
| bool append_element | ( | T | element | ) |
append array element to the end of array
| element | element to append |
Definition at line 132 of file DynamicArray.h.
| T back | ( | ) |
STD VECTOR compatible. Return array element at the end of array.
Definition at line 158 of file DynamicArray.h.
| void clear_array | ( | ) |
clear the array (with zeros)
Definition at line 220 of file DynamicArray.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 180 of file DynamicArray.h.
| int32_t find_element | ( | T | element | ) |
find first occurence of array element and return its index or -1 if not available
| element | element to search for |
Definition at line 169 of file DynamicArray.h.
| T* get_array | ( | ) | const |
get the array call get_array just before messing with it DO NOT call any [],resize/delete functions after get_array(), the pointer may become invalid !
Definition at line 202 of file DynamicArray.h.
| int32_t get_array_size | ( | ) |
get array size (including granularity buffer)
Definition at line 67 of file DynamicArray.h.
| T get_element | ( | int32_t | index | ) | const |
get array element at index
(does NOT do bounds checking)
| index | index |
Definition at line 88 of file DynamicArray.h.
| T get_element_safe | ( | int32_t | index | ) | const |
get array element at index
(does bounds checking)
| index | index |
Definition at line 100 of file DynamicArray.h.
|
virtual |
| int32_t get_num_elements | ( | ) | const |
| bool insert_element | ( | T | element, |
| int32_t | index | ||
| ) |
insert array element at index
| element | element to insert |
| index | index |
Definition at line 122 of file DynamicArray.h.
| CDynamicArray<T>& operator= | ( | CDynamicArray< T > & | orig | ) |
operator overload for array assignment
| orig | original array |
Definition at line 244 of file DynamicArray.h.
| T operator[] | ( | int32_t | index | ) | const |
operator overload for array read only access use set_element() for write access (will also make the array dynamically grow)
DOES NOT DO ANY BOUNDS CHECKING
| index | index |
Definition at line 234 of file DynamicArray.h.
| void pop_back | ( | ) |
STD VECTOR compatible. Delete array element at the end of array.
Definition at line 148 of file DynamicArray.h.
| void push_back | ( | T | element | ) |
STD VECTOR compatible. Append array element to the end of array.
| element | element to append |
Definition at line 142 of file DynamicArray.h.
| bool resize_array | ( | int32_t | n | ) |
resize the array
| n | new size |
Definition at line 190 of file DynamicArray.h.
| void set_array | ( | T * | p_array, |
| int32_t | p_num_elements, | ||
| int32_t | array_size | ||
| ) |
set the array pointer and free previously allocated memory
| p_array | new array |
| p_num_elements | last element index + 1 |
| array_size | number of elements in array |
Definition at line 213 of file DynamicArray.h.
| bool set_element | ( | T | element, |
| int32_t | index | ||
| ) |
set array element at index
| element | element to set |
| index | index |
Definition at line 111 of file DynamicArray.h.
| int32_t set_granularity | ( | int32_t | g | ) |
set the resize granularity
| g | new granularity |
Definition at line 58 of file DynamicArray.h.
| void shuffle | ( | ) |
shuffles the array
Definition at line 251 of file DynamicArray.h.
|
protected |
underlying array
Definition at line 262 of file DynamicArray.h.