12 #ifndef _DYNAMIC_OBJECT_ARRAY_H_
13 #define _DYNAMIC_OBJECT_ARRAY_H_
52 :
CSGObject(), m_array(dim1*dim2*dim3), name(
"Array")
69 :
CSGObject(), m_array(p_array, p_dim1_size, p_free_array, p_copy_array), name(
"Array")
71 dim1_size=p_dim1_size;
87 bool p_free_array=
true,
bool p_copy_array=
false)
88 :
CSGObject(), m_array(p_array, p_dim1_size*p_dim2_size, p_free_array, p_copy_array), name(
"Array")
90 dim1_size=p_dim1_size;
91 dim2_size=p_dim2_size;
107 int32_t p_dim3_size,
bool p_free_array=
true,
bool p_copy_array=
false)
108 :
CSGObject(), m_array(p_array, p_dim1_size*p_dim2_size*p_dim3_size, p_free_array, p_copy_array), name(
"Array")
110 dim1_size=p_dim1_size;
111 dim2_size=p_dim2_size;
112 dim3_size=p_dim3_size;
125 {
return m_array.set_granularity(g); }
133 return m_array.get_array_size();
184 return m_array.get_num_elements();
196 CSGObject* elem=m_array.get_element(index);
210 return get_element(idx1+dim1_size*(idx2+dim2_size*idx3));
233 CSGObject* e=m_array.get_element_safe(index);
248 int32_t idx = idx1+dim1_size*(idx2+dim2_size*idx3);
252 old = (
CSGObject*) m_array.get_element(idx);
254 bool success=m_array.set_element(e, idx);
273 bool success=m_array.insert_element(e, index);
287 bool success=m_array.append_element(e);
302 m_array.push_back(e);
336 return m_array.find_element(elem);
349 m_array.set_element(NULL, idx);
351 return m_array.delete_element(idx);
358 m_array.clear_array(NULL);
383 m_array=orig.m_array;
413 {
return "DynamicObjectArray"; }
427 m_array.resize_array(m_array.get_num_elements(),
true);
442 m_array.resize_array(m_array.get_num_elements(),
true);
451 "Memory for dynamic array.");
452 SG_ADD(&m_array.num_elements,
455 SG_ADD(&m_array.resize_granularity,
456 "resize_granularity",
458 SG_ADD(&m_array.use_sg_mallocs,
460 "whether SG_MALLOC or malloc should be used",
462 SG_ADD(&m_array.free_array,
464 "whether array must be freed",
469 inline void unref_all()
472 for (
index_t i=0; i<m_array.get_num_elements(); ++i)
474 SG_UNREF(*m_array.get_element_ptr(i));
480 DynArray<CSGObject*> m_array;
virtual void load_serializable_pre()
const char * get_array_name() const
CDynamicObjectArray & operator=(CDynamicObjectArray &orig)
CDynamicObjectArray(CSGObject **p_array, int32_t p_dim1_size, int32_t p_dim2_size, int32_t p_dim3_size, bool p_free_array=true, bool p_copy_array=false)
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
void shuffle(CRandom *rand)
bool insert_element(CSGObject *e, int32_t index)
CDynamicObjectArray(int32_t dim1, int32_t dim2=1, int32_t dim3=1)
virtual void save_serializable_pre()
int32_t get_num_elements() const
int32_t find_element(CSGObject *elem) const
bool set_element(CSGObject *e, int32_t idx1, int32_t idx2=0, int32_t idx3=0)
CSGObject ** get_array() const
virtual void save_serializable_pre()
virtual const char * get_name() const
Class SGObject is the base class of all shogun objects.
CSGObject * element(int32_t idx1, int32_t idx2=0, int32_t idx3=0)
virtual ~CDynamicObjectArray()
CDynamicObjectArray(CSGObject **p_array, int32_t p_dim1_size, bool p_free_array=true, bool p_copy_array=false)
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
void get_array_size(int32_t &dim1, int32_t &dim2)
: Pseudo random number geneartor
virtual void load_serializable_pre()
void get_array_size(int32_t &dim1, int32_t &dim2, int32_t &dim3)
void add_vector(bool **param, index_t *length, const char *name, const char *description="")
all of classes and functions are contained in the shogun namespace
CSGObject * get_element_safe(int32_t index) const
CSGObject * get_element(int32_t index) const
void push_back(CSGObject *e)
bool delete_element(int32_t idx)
CSGObject * get_last_element() const
void set_array_name(const char *p_name)
int32_t set_granularity(int32_t g)
CDynamicObjectArray(CSGObject **p_array, int32_t p_dim1_size, int32_t p_dim2_size, bool p_free_array=true, bool p_copy_array=false)
bool append_element(CSGObject *e)