SHOGUN  v3.2.0
所有成员列表 | Public 成员函数 | Protected 属性 | 友元
DynArray< T > 模板类 参考

详细描述

template<class T>
class 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.h30 行定义.

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

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

constructor

参数
p_resize_granularityresize granularity
tracable

在文件 DynArray.h42 行定义.

◆ DynArray() [2/3]

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.h65 行定义.

◆ DynArray() [3/3]

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

constructor

参数
p_arrayanother array
p_array_sizearray's size
tracable

在文件 DynArray.h81 行定义.

◆ ~DynArray()

virtual ~DynArray ( )
virtual

destructor

在文件 DynArray.h92 行定义.

成员函数说明

◆ append_element()

bool append_element ( element)

append array element to the end of array

参数
elementelement to append
返回
if setting was successful

在文件 DynArray.h242 行定义.

◆ back()

T back ( ) const

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

返回
element at the end of array

在文件 DynArray.h276 行定义.

◆ clear_array()

void clear_array ( value)

clear the array (with e.g. zeros)

在文件 DynArray.h429 行定义.

◆ delete_element()

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.h313 行定义.

◆ find_element()

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.h290 行定义.

◆ get_array()

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.h370 行定义.

◆ get_array_size()

int32_t get_array_size ( ) const

get array size (including granularity buffer)

返回
total array size (including granularity buffer)

在文件 DynArray.h119 行定义.

◆ get_element()

T get_element ( int32_t  index) const

get array element at index

(does NOT do bounds checking)

参数
indexindex
返回
array element at index

在文件 DynArray.h140 行定义.

◆ get_element_ptr()

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.h161 行定义.

◆ get_element_safe()

T get_element_safe ( int32_t  index) const

get array element at index

(does bounds checking)

参数
indexindex
返回
array element at index

在文件 DynArray.h173 行定义.

◆ get_last_element()

T get_last_element ( ) const

gets last array element

返回
array element at last index

在文件 DynArray.h149 行定义.

◆ get_name()

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

在文件 DynArray.h509 行定义.

◆ get_num_elements()

int32_t get_num_elements ( ) const

get number of elements

返回
number of elements

在文件 DynArray.h128 行定义.

◆ insert_element()

bool insert_element ( element,
int32_t  index 
)

insert array element at index

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

在文件 DynArray.h221 行定义.

◆ operator=()

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

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

参数
origoriginal array
返回
new array

在文件 DynArray.h486 行定义.

◆ operator[]()

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.h475 行定义.

◆ pop_back()

void pop_back ( )

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

在文件 DynArray.h263 行定义.

◆ push_back()

void push_back ( element)

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

参数
elementelement to append

在文件 DynArray.h252 行定义.

◆ reset()

void reset ( value)

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

在文件 DynArray.h439 行定义.

◆ resize_array()

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.h338 行定义.

◆ set_array() [1/2]

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.h383 行定义.

◆ set_array() [2/2]

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.h411 行定义.

◆ set_const()

void set_const ( const T &  const_element)

set array with a constant

在文件 DynArray.h460 行定义.

◆ set_element()

bool set_element ( element,
int32_t  index 
)

set array element at index

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

在文件 DynArray.h189 行定义.

◆ set_granularity()

int32_t set_granularity ( int32_t  g)

set the resize granularity

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

在文件 DynArray.h108 行定义.

◆ shuffle() [1/2]

void shuffle ( )

randomizes the array (not thread safe!)

在文件 DynArray.h446 行定义.

◆ shuffle() [2/2]

void shuffle ( CRandom rand)

randomizes the array with external random state

在文件 DynArray.h453 行定义.

友元及相关函数文档

◆ CCommUlongStringKernel

friend class CCommUlongStringKernel
friend

在文件 DynArray.h34 行定义.

◆ CDynamicArray

friend class CDynamicArray
friend

在文件 DynArray.h32 行定义.

◆ CDynamicObjectArray

friend class CDynamicObjectArray
friend

在文件 DynArray.h33 行定义.

类成员变量说明

◆ array

T* array
protected

memory for dynamic array

在文件 DynArray.h516 行定义.

◆ current_num_elements

int32_t current_num_elements
protected

the number of currently used elements

在文件 DynArray.h522 行定义.

◆ free_array

bool free_array
protected

if array must be freed

在文件 DynArray.h528 行定义.

◆ num_elements

int32_t num_elements
protected

the number of potentially used elements in array

在文件 DynArray.h519 行定义.

◆ resize_granularity

int32_t resize_granularity
protected

shrink/grow step size

在文件 DynArray.h513 行定义.

◆ use_sg_mallocs

bool use_sg_mallocs
protected

whether SG_MALLOC or just malloc etc shall be used

在文件 DynArray.h525 行定义.


该类的文档由以下文件生成:

SHOGUN Machine Learning Toolbox - Documentation