SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
SGDynamicRefObjectArray Class Reference

Detailed Description

Dynamic array class for CRefObject pointers 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 CRefObject pointers, which ARE automagically SG_REF'd/deleted.

This array is optimized to have very little (storage) overhead

Definition at line 33 of file SGDynamicRefObjectArray.h.

Inheritance diagram for SGDynamicRefObjectArray:
Inheritance graph
[legend]

Public Member Functions

 SGDynamicRefObjectArray ()
 SGDynamicRefObjectArray (int32_t dim1, int32_t dim2=1, int32_t dim3=1)
 SGDynamicRefObjectArray (CRefObject **p_array, int32_t p_dim1_size, bool p_free_array=true, bool p_copy_array=false)
 SGDynamicRefObjectArray (CRefObject **p_array, int32_t p_dim1_size, int32_t p_dim2_size, bool p_free_array=true, bool p_copy_array=false)
 SGDynamicRefObjectArray (CRefObject **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)
virtual ~SGDynamicRefObjectArray ()
int32_t set_granularity (int32_t g)
int32_t get_array_size ()
void get_array_size (int32_t &dim1, int32_t &dim2)
void get_array_size (int32_t &dim1, int32_t &dim2, int32_t &dim3)
int32_t get_dim1 ()
int32_t get_dim2 ()
int32_t get_dim3 ()
int32_t get_num_elements () const
CRefObject * get_element (int32_t index) const
CRefObject * element (int32_t idx1, int32_t idx2=0, int32_t idx3=0)
CRefObject * get_last_element () const
CRefObject * get_element_safe (int32_t index) const
bool set_element (CRefObject *e, int32_t idx1, int32_t idx2=0, int32_t idx3=0)
bool insert_element (CRefObject *e, int32_t index)
bool append_element (CRefObject *e)
void push_back (CRefObject *e)
void pop_back ()
CRefObject * back () const
int32_t find_element (CRefObject *elem) const
bool delete_element (int32_t idx)
void clear_array ()
void reset_array ()
SGDynamicRefObjectArrayoperator= (SGDynamicRefObjectArray &orig)
CRefObject ** get_array () const
void shuffle ()
void shuffle (CRandom *rand)
void set_array_name (const char *p_name)
const char * get_array_name () const
virtual const char * get_name () const

Constructor & Destructor Documentation

default constructor

Definition at line 37 of file SGDynamicRefObjectArray.h.

SGDynamicRefObjectArray ( int32_t  dim1,
int32_t  dim2 = 1,
int32_t  dim3 = 1 
)

constructor

Parameters
dim1dimension 1
dim2dimension 2
dim3dimension 3

Definition at line 51 of file SGDynamicRefObjectArray.h.

SGDynamicRefObjectArray ( CRefObject **  p_array,
int32_t  p_dim1_size,
bool  p_free_array = true,
bool  p_copy_array = false 
)

constructor

Parameters
p_arrayanother array
p_dim1_sizedimension 1
p_free_arrayif array must be freed
p_copy_arrayif array must be copied

Definition at line 66 of file SGDynamicRefObjectArray.h.

SGDynamicRefObjectArray ( CRefObject **  p_array,
int32_t  p_dim1_size,
int32_t  p_dim2_size,
bool  p_free_array = true,
bool  p_copy_array = false 
)

constructor

Parameters
p_arrayanother array
p_dim1_sizedimension 1
p_dim2_sizedimension 2
p_free_arrayif array must be freed
p_copy_arrayif array must be copied

Definition at line 82 of file SGDynamicRefObjectArray.h.

SGDynamicRefObjectArray ( CRefObject **  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 
)

constructor

Parameters
p_arrayanother array
p_dim1_sizedimension 1
p_dim2_sizedimension 2
p_dim3_sizedimension 3
p_free_arrayif array must be freed
p_copy_arrayif array must be copied

Definition at line 100 of file SGDynamicRefObjectArray.h.

virtual ~SGDynamicRefObjectArray ( )
virtual

Definition at line 109 of file SGDynamicRefObjectArray.h.

Member Function Documentation

bool append_element ( CRefObject *  e)

append array element to the end of array

Parameters
eelement to append
Returns
if setting was successful

Definition at line 277 of file SGDynamicRefObjectArray.h.

CRefObject* back ( ) const

STD VECTOR compatible. Return array element at the end of array.

Returns
element at the end of array

Definition at line 313 of file SGDynamicRefObjectArray.h.

void clear_array ( )

clear the array (with zeros)

Definition at line 347 of file SGDynamicRefObjectArray.h.

bool delete_element ( int32_t  idx)

delete array element at idx (does not call SG_FREE() or the like)

Parameters
idxindex
Returns
if deleting was successful

Definition at line 337 of file SGDynamicRefObjectArray.h.

CRefObject* element ( int32_t  idx1,
int32_t  idx2 = 0,
int32_t  idx3 = 0 
)

get array element at index

Parameters
idx1index 1
idx2index 2
idx3index 3
Returns
array element at index

Definition at line 200 of file SGDynamicRefObjectArray.h.

int32_t find_element ( CRefObject *  elem) const

find first occurence of array element and return its index or -1 if not available

Parameters
elemelement to search for
Returns
index of element or -1

Definition at line 326 of file SGDynamicRefObjectArray.h.

CRefObject** get_array ( ) const
Returns
underlying array of pointers

Definition at line 380 of file SGDynamicRefObjectArray.h.

const char* get_array_name ( ) const

get array's name

Returns
array's name

Definition at line 401 of file SGDynamicRefObjectArray.h.

int32_t get_array_size ( )

get array size (including granularity buffer)

Returns
total array size (including granularity buffer)

Definition at line 123 of file SGDynamicRefObjectArray.h.

void get_array_size ( int32_t &  dim1,
int32_t &  dim2 
)

return 2d array size

Parameters
dim1dimension 1 will be stored here
dim2dimension 2 will be stored here

Definition at line 133 of file SGDynamicRefObjectArray.h.

void get_array_size ( int32_t &  dim1,
int32_t &  dim2,
int32_t &  dim3 
)

return 3d array size

Parameters
dim1dimension 1 will be stored here
dim2dimension 2 will be stored here
dim3dimension 3 will be stored here

Definition at line 145 of file SGDynamicRefObjectArray.h.

int32_t get_dim1 ( )

get dimension 1

Returns
dimension 1

Definition at line 156 of file SGDynamicRefObjectArray.h.

int32_t get_dim2 ( )

get dimension 2

Returns
dimension 2

Definition at line 162 of file SGDynamicRefObjectArray.h.

int32_t get_dim3 ( )

get dimension 3

Returns
dimension 3

Definition at line 168 of file SGDynamicRefObjectArray.h.

CRefObject* get_element ( int32_t  index) const

get array element at index

(does NOT do bounds checking)

Parameters
indexindex
Returns
array element at index

Definition at line 186 of file SGDynamicRefObjectArray.h.

CRefObject* get_element_safe ( int32_t  index) const

get array element at index

(does bounds checking)

Parameters
indexindex
Returns
array element at index

Definition at line 223 of file SGDynamicRefObjectArray.h.

CRefObject* get_last_element ( ) const

get last array element

Returns
last array element

Definition at line 209 of file SGDynamicRefObjectArray.h.

virtual const char* get_name ( ) const
virtual
Returns
object name

Implements SGRefObject.

Definition at line 404 of file SGDynamicRefObjectArray.h.

int32_t get_num_elements ( ) const

get number of elements

Returns
number of elements

Definition at line 174 of file SGDynamicRefObjectArray.h.

bool insert_element ( CRefObject *  e,
int32_t  index 
)

insert array element at index

Parameters
eelement to insert
indexindex
Returns
if setting was successful

Definition at line 263 of file SGDynamicRefObjectArray.h.

operator overload for array assignment

Parameters
origoriginal array
Returns
new array

Definition at line 365 of file SGDynamicRefObjectArray.h.

void pop_back ( )

STD VECTOR compatible. Delete array element at the end of array.

Definition at line 300 of file SGDynamicRefObjectArray.h.

void push_back ( CRefObject *  e)

STD VECTOR compatible. Append array element to the end of array.

Parameters
eelement to append

Definition at line 291 of file SGDynamicRefObjectArray.h.

void reset_array ( )

resets the array

Definition at line 354 of file SGDynamicRefObjectArray.h.

void set_array_name ( const char *  p_name)

set array's name

Parameters
p_namenew name

Definition at line 392 of file SGDynamicRefObjectArray.h.

bool set_element ( CRefObject *  e,
int32_t  idx1,
int32_t  idx2 = 0,
int32_t  idx3 = 0 
)

set array element at index

Parameters
eelement to set
idx1index 1
idx2index 2
idx3index 2
Returns
if setting was successful

Definition at line 238 of file SGDynamicRefObjectArray.h.

int32_t set_granularity ( int32_t  g)

set the resize granularity

Parameters
gnew granularity
Returns
what has been set (minimum is 128)

Definition at line 116 of file SGDynamicRefObjectArray.h.

void shuffle ( )

shuffles the array (not thread safe!)

Definition at line 383 of file SGDynamicRefObjectArray.h.

void shuffle ( CRandom rand)

shuffles the array with external random state

Definition at line 386 of file SGDynamicRefObjectArray.h.


The documentation for this class was generated from the following file:

SHOGUN Machine Learning Toolbox - Documentation