18 #define ARRAY_ASSERT(x)
25 #ifdef ARRAY_STATISTICS
26 struct array_statistics {
27 int32_t const_element;
31 int32_t operator_overload;
32 int32_t const_operator_overload;
36 int32_t array_element;
39 #define DECLARE_ARRAY_STATISTICS struct array_statistics as
40 #define INIT_ARRAY_STATISTICS memset(&as, 0, sizeof(as))
41 #define PRINT_ARRAY_STATISTICS \
42 SG_DEBUG("access statistics:\n" \
43 "const element %i\n" \
47 "operator_overload[] %i\n" \
48 "const_operator_overload[] %i\n" \
52 "array_element %i\n", \
57 as.operator_overload, \
58 as.const_operator_overload, \
65 #define INCREMENT_ARRAY_STATISTICS_VALUE(_val_) ((CArray<T>*)this)->as._val_++
68 #define DECLARE_ARRAY_STATISTICS
69 #define INIT_ARRAY_STATISTICS
70 #define PRINT_ARRAY_STATISTICS
71 #define INCREMENT_ARRAY_STATISTICS_VALUE(_val_)
103 CArray(T* p_array, int32_t p_array_size,
bool p_free_array=
true,
104 bool p_copy_array=
false)
108 set_array(p_array, p_array_size, p_free_array, p_copy_array);
116 CArray(
const T* p_array, int32_t p_array_size)
134 inline virtual const char*
get_name()
const {
return "Array"; }
180 array[i]=const_elem ;
205 array[index]=p_element;
245 return p_array[index];
285 inline void set_array(T* p_array, int32_t p_array_size,
bool p_free_array=
true,
286 bool copy_array=
false)
293 memcpy(this->
array, p_array, p_array_size*
sizeof(T));
306 inline void set_array(
const T* p_array, int32_t p_array_size)
311 memcpy(this->
array, p_array, p_array_size*
sizeof(T));
CArray< T > & operator=(const CArray< T > &orig)
const T & operator[](int32_t index) const
void set_array_name(const char *p_name)
CArray(T *p_array, int32_t p_array_size, bool p_free_array=true, bool p_copy_array=false)
bool set_element(const T &p_element, int32_t index)
virtual const char * get_name() const
void display_size() const
const T & get_element(int32_t index) const
CArray(int32_t initial_size=1)
T & element(int32_t index)
bool resize_array(int32_t n)
Class SGObject is the base class of all shogun objects.
T & element(T *p_array, int32_t index)
void display_array() const
CArray(const T *p_array, int32_t p_array_size)
#define PRINT_ARRAY_STATISTICS
int32_t get_array_size() const
#define INIT_ARRAY_STATISTICS
#define SG_REALLOC(type, ptr, len)
T & operator[](int32_t index)
virtual const char * get_array_name() const
const T & element(int32_t idx1) const
void set_array(T *p_array, int32_t p_array_size, bool p_free_array=true, bool copy_array=false)
#define INCREMENT_ARRAY_STATISTICS_VALUE(_val_)
void set_array(const T *p_array, int32_t p_array_size)
Template class Array implements a dense one dimensional array.
#define SG_MALLOC(type, len)
void set_const(T const_elem)