SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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 31 of file SGDynamicRefObjectArray.h.

Inheritance diagram for SGDynamicRefObjectArray:
Inheritance graph
[legend]

List of all members.

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 35 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 49 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 64 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 80 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 98 of file SGDynamicRefObjectArray.h.

virtual ~SGDynamicRefObjectArray ( ) [virtual]

Definition at line 107 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 275 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 311 of file SGDynamicRefObjectArray.h.

void clear_array ( )

clear the array (with zeros)

Definition at line 345 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 335 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 198 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 324 of file SGDynamicRefObjectArray.h.

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

Definition at line 378 of file SGDynamicRefObjectArray.h.

const char* get_array_name ( ) const

get array's name

Returns:
array's name

Definition at line 399 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 121 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 131 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 143 of file SGDynamicRefObjectArray.h.

int32_t get_dim1 ( )

get dimension 1

Returns:
dimension 1

Definition at line 154 of file SGDynamicRefObjectArray.h.

int32_t get_dim2 ( )

get dimension 2

Returns:
dimension 2

Definition at line 160 of file SGDynamicRefObjectArray.h.

int32_t get_dim3 ( )

get dimension 3

Returns:
dimension 3

Definition at line 166 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 184 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 221 of file SGDynamicRefObjectArray.h.

CRefObject* get_last_element ( ) const

get last array element

Returns:
last array element

Definition at line 207 of file SGDynamicRefObjectArray.h.

virtual const char* get_name ( ) const [virtual]
Returns:
object name

Implements SGRefObject.

Definition at line 402 of file SGDynamicRefObjectArray.h.

int32_t get_num_elements ( ) const

get number of elements

Returns:
number of elements

Definition at line 172 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 261 of file SGDynamicRefObjectArray.h.

operator overload for array assignment

Parameters:
origoriginal array
Returns:
new array

Definition at line 363 of file SGDynamicRefObjectArray.h.

void pop_back ( )

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

Definition at line 298 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 289 of file SGDynamicRefObjectArray.h.

void reset_array ( )

resets the array

Definition at line 352 of file SGDynamicRefObjectArray.h.

void set_array_name ( const char *  p_name)

set array's name

Parameters:
p_namenew name

Definition at line 390 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 236 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 114 of file SGDynamicRefObjectArray.h.

void shuffle ( )

shuffles the array (not thread safe!)

Definition at line 381 of file SGDynamicRefObjectArray.h.

void shuffle ( CRandom rand)

shuffles the array with external random state

Definition at line 384 of file SGDynamicRefObjectArray.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation