SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
所有成员列表 | Public 成员函数 | Protected 属性 | 友元
DynArray< T > Singleton Reference

详细描述

template<class T>
singleton shogun::DynArray< T >

Template Dynamic array class 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 is performance tuned for simple types like float etc. and for hi-level objects only stores pointers, which are not automagically SG_REF'd/deleted.

在文件 DynArray.h32 行定义.

Public 成员函数

 DynArray (int32_t p_resize_granularity=128, bool tracable=true)
 
 DynArray (T *p_array, int32_t p_array_size, bool p_free_array, bool p_copy_array, bool tracable=true)
 
 DynArray (const T *p_array, int32_t p_array_size, bool tracable=true)
 
virtual ~DynArray ()
 
int32_t set_granularity (int32_t g)
 
int32_t get_array_size () const
 
int32_t get_num_elements () const
 
get_element (int32_t index) const
 
get_last_element () const
 
T * get_element_ptr (int32_t index)
 
get_element_safe (int32_t index) const
 
bool set_element (T element, int32_t index)
 
bool insert_element (T element, int32_t index)
 
bool append_element (T element)
 
void push_back (T element)
 
void pop_back ()
 
back () const
 
int32_t find_element (T element) const
 
bool delete_element (int32_t idx)
 
bool resize_array (int32_t n, bool exact_resize=false)
 
T * get_array () const
 
void set_array (T *p_array, int32_t p_num_elements, int32_t p_array_size, bool p_free_array, bool p_copy_array)
 
void set_array (const T *p_array, int32_t p_num_elements, int32_t p_array_size)
 
void clear_array (T value)
 
void reset (T value)
 
void shuffle ()
 
void shuffle (CRandom *rand)
 
void set_const (const T &const_element)
 
operator[] (int32_t index) const
 
DynArray< T > & operator= (DynArray< T > &orig)
 
virtual const char * get_name () const
 

Protected 属性

int32_t resize_granularity
 
T * array
 
int32_t num_elements
 
int32_t current_num_elements
 
bool use_sg_mallocs
 
bool free_array
 

友元

template<class U >
class CDynamicArray
 
class CDynamicObjectArray
 
class CCommUlongStringKernel
 

构造及析构函数说明

DynArray ( int32_t  p_resize_granularity = 128,
bool  tracable = true 
)

constructor

参数
p_resize_granularityresize granularity
tracable

在文件 DynArray.h44 行定义.

DynArray ( T *  p_array,
int32_t  p_array_size,
bool  p_free_array,
bool  p_copy_array,
bool  tracable = true 
)

constructor

参数
p_arrayanother array
p_array_sizearray's size
p_free_arrayif array must be freed
p_copy_arrayif array must be copied
tracable

在文件 DynArray.h67 行定义.

DynArray ( const T *  p_array,
int32_t  p_array_size,
bool  tracable = true 
)

constructor

参数
p_arrayanother array
p_array_sizearray's size
tracable

在文件 DynArray.h83 行定义.

virtual ~DynArray ( )
virtual

destructor

在文件 DynArray.h94 行定义.

成员函数说明

bool append_element ( element)

append array element to the end of array

参数
elementelement to append
返回
if setting was successful

在文件 DynArray.h244 行定义.

T back ( ) const

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

返回
element at the end of array

在文件 DynArray.h278 行定义.

void clear_array ( value)

clear the array (with e.g. zeros)

在文件 DynArray.h431 行定义.

bool delete_element ( int32_t  idx)

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

参数
idxindex
返回
if deleting was successful

在文件 DynArray.h315 行定义.

int32_t find_element ( element) const

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

参数
elementelement to search for
返回
index of element or -1

在文件 DynArray.h292 行定义.

T* get_array ( ) const

get the array call get_array just before messing with it DO NOT call any [],resize/delete functions after get_array(), the pointer may become invalid !

返回
the array

在文件 DynArray.h372 行定义.

int32_t get_array_size ( ) const

get array size (including granularity buffer)

返回
total array size (including granularity buffer)

在文件 DynArray.h121 行定义.

T get_element ( int32_t  index) const

get array element at index

(does NOT do bounds checking)

参数
indexindex
返回
array element at index

在文件 DynArray.h142 行定义.

T* get_element_ptr ( int32_t  index)

get array element at index as pointer

(does NOT do bounds checking)

参数
indexindex
返回
array element at index

在文件 DynArray.h163 行定义.

T get_element_safe ( int32_t  index) const

get array element at index

(does bounds checking)

参数
indexindex
返回
array element at index

在文件 DynArray.h175 行定义.

T get_last_element ( ) const

gets last array element

返回
array element at last index

在文件 DynArray.h151 行定义.

virtual const char* get_name ( ) const
virtual
返回
object name

在文件 DynArray.h511 行定义.

int32_t get_num_elements ( ) const

get number of elements

返回
number of elements

在文件 DynArray.h130 行定义.

bool insert_element ( element,
int32_t  index 
)

insert array element at index

参数
elementelement to insert
indexindex
返回
if setting was successful

在文件 DynArray.h223 行定义.

DynArray<T>& operator= ( DynArray< T > &  orig)

operator overload for array assignment. Left array is resized if needed.

参数
origoriginal array
返回
new array

在文件 DynArray.h488 行定义.

T operator[] ( int32_t  index) const

operator overload for array read only access use set_element() for write access (will also make the array dynamically grow)

DOES NOT DO ANY BOUNDS CHECKING

参数
indexindex
返回
element at index

在文件 DynArray.h477 行定义.

void pop_back ( )

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

在文件 DynArray.h265 行定义.

void push_back ( element)

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

参数
elementelement to append

在文件 DynArray.h254 行定义.

void reset ( value)

resets the array (as if it was just created), keeps granularity

在文件 DynArray.h441 行定义.

bool resize_array ( int32_t  n,
bool  exact_resize = false 
)

resize the array

参数
nnew size
exact_resizeresize exactly to size n
返回
if resizing was successful

在文件 DynArray.h340 行定义.

void set_array ( T *  p_array,
int32_t  p_num_elements,
int32_t  p_array_size,
bool  p_free_array,
bool  p_copy_array 
)

set the array pointer and free previously allocated memory

参数
p_arraynew array
p_num_elementslast element index + 1
p_array_sizenumber of elements in array
p_free_arrayif array must be freed
p_copy_arrayif array must be copied

在文件 DynArray.h385 行定义.

void set_array ( const T *  p_array,
int32_t  p_num_elements,
int32_t  p_array_size 
)

set the array pointer and free previously allocated memory

参数
p_arraynew array
p_num_elementslast element index + 1
p_array_sizenumber of elements in array

在文件 DynArray.h413 行定义.

void set_const ( const T &  const_element)

set array with a constant

在文件 DynArray.h462 行定义.

bool set_element ( element,
int32_t  index 
)

set array element at index

参数
elementelement to set
indexindex
返回
if setting was successful

在文件 DynArray.h191 行定义.

int32_t set_granularity ( int32_t  g)

set the resize granularity

参数
gnew granularity
返回
what has been set (minimum is 128)

在文件 DynArray.h110 行定义.

void shuffle ( )

randomizes the array (not thread safe!)

在文件 DynArray.h448 行定义.

void shuffle ( CRandom rand)

randomizes the array with external random state

在文件 DynArray.h455 行定义.

友元及相关函数文档

friend class CCommUlongStringKernel
friend

在文件 DynArray.h36 行定义.

friend class CDynamicArray
friend

在文件 DynArray.h34 行定义.

friend class CDynamicObjectArray
friend

在文件 DynArray.h35 行定义.

类成员变量说明

T* array
protected

memory for dynamic array

在文件 DynArray.h518 行定义.

int32_t current_num_elements
protected

the number of currently used elements

在文件 DynArray.h524 行定义.

bool free_array
protected

if array must be freed

在文件 DynArray.h530 行定义.

int32_t num_elements
protected

the number of potentially used elements in array

在文件 DynArray.h521 行定义.

int32_t resize_granularity
protected

shrink/grow step size

在文件 DynArray.h515 行定义.

bool use_sg_mallocs
protected

whether SG_MALLOC or just malloc etc shall be used

在文件 DynArray.h527 行定义.


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

SHOGUN 机器学习工具包 - 项目文档