SHOGUN  v3.2.0
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 31 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

◆ SGDynamicRefObjectArray() [1/5]

default constructor

Definition at line 35 of file SGDynamicRefObjectArray.h.

◆ SGDynamicRefObjectArray() [2/5]

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() [3/5]

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() [4/5]

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() [5/5]

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.

◆ ~SGDynamicRefObjectArray()

virtual ~SGDynamicRefObjectArray ( )
virtual

Definition at line 107 of file SGDynamicRefObjectArray.h.

Member Function Documentation

◆ append_element()

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.

◆ back()

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.

◆ clear_array()

void clear_array ( )

clear the array (with zeros)

Definition at line 345 of file SGDynamicRefObjectArray.h.

◆ delete_element()

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.

◆ element()

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.

◆ find_element()

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.

◆ get_array()

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

Definition at line 378 of file SGDynamicRefObjectArray.h.

◆ get_array_name()

const char* get_array_name ( ) const

get array's name

Returns
array's name

Definition at line 399 of file SGDynamicRefObjectArray.h.

◆ get_array_size() [1/3]

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.

◆ get_array_size() [2/3]

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.

◆ get_array_size() [3/3]

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.

◆ get_dim1()

int32_t get_dim1 ( )

get dimension 1

Returns
dimension 1

Definition at line 154 of file SGDynamicRefObjectArray.h.

◆ get_dim2()

int32_t get_dim2 ( )

get dimension 2

Returns
dimension 2

Definition at line 160 of file SGDynamicRefObjectArray.h.

◆ get_dim3()

int32_t get_dim3 ( )

get dimension 3

Returns
dimension 3

Definition at line 166 of file SGDynamicRefObjectArray.h.

◆ get_element()

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.

◆ get_element_safe()

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.

◆ get_last_element()

CRefObject* get_last_element ( ) const

get last array element

Returns
last array element

Definition at line 207 of file SGDynamicRefObjectArray.h.

◆ get_name()

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

Implements SGRefObject.

Definition at line 402 of file SGDynamicRefObjectArray.h.

◆ get_num_elements()

int32_t get_num_elements ( ) const

get number of elements

Returns
number of elements

Definition at line 172 of file SGDynamicRefObjectArray.h.

◆ insert_element()

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=()

operator overload for array assignment

Parameters
origoriginal array
Returns
new array

Definition at line 363 of file SGDynamicRefObjectArray.h.

◆ pop_back()

void pop_back ( )

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

Definition at line 298 of file SGDynamicRefObjectArray.h.

◆ push_back()

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.

◆ reset_array()

void reset_array ( )

resets the array

Definition at line 352 of file SGDynamicRefObjectArray.h.

◆ set_array_name()

void set_array_name ( const char *  p_name)

set array's name

Parameters
p_namenew name

Definition at line 390 of file SGDynamicRefObjectArray.h.

◆ set_element()

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.

◆ set_granularity()

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.

◆ shuffle() [1/2]

void shuffle ( )

shuffles the array (not thread safe!)

Definition at line 381 of file SGDynamicRefObjectArray.h.

◆ shuffle() [2/2]

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:

SHOGUN Machine Learning Toolbox - Documentation