SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
CArray< T > Class Template Reference

Detailed Description

template<class T>
class shogun::CArray< T >

Template class Array implements a dense one dimensional array.

Note that depending on compile options everything will be inlined, such that this is as high performance array implementation without error checking.

Definition at line 80 of file Array.h.

Inheritance diagram for CArray< T >:
Inheritance graph
[legend]

Public Member Functions

 CArray (int32_t initial_size=1)
 CArray (T *p_array, int32_t p_array_size, bool p_free_array=true, bool p_copy_array=false)
 CArray (const T *p_array, int32_t p_array_size)
virtual ~CArray ()
virtual const char * get_name () const
virtual const char * get_array_name () const
void set_array_name (const char *p_name)
int32_t get_array_size () const
int32_t get_dim1 ()
void zero ()
void set_const (T const_elem)
const T & get_element (int32_t index) const
bool set_element (const T &p_element, int32_t index)
const T & element (int32_t idx1) const
T & element (int32_t index)
T & element (T *p_array, int32_t index)
bool resize_array (int32_t n)
T * get_array ()
void set_array (T *p_array, int32_t p_array_size, bool p_free_array=true, bool copy_array=false)
void set_array (const T *p_array, int32_t p_array_size)
void clear_array ()
const T & operator[] (int32_t index) const
T & operator[] (int32_t index)
CArray< T > & operator= (const CArray< T > &orig)
void display_size () const
void display_array () const
- Public Member Functions inherited from CSGObject
 CSGObject ()
 CSGObject (const CSGObject &orig)
virtual ~CSGObject ()
virtual bool is_generic (EPrimitiveType *generic) const
template<class T >
void set_generic ()
void unset_generic ()
virtual void print_serializable (const char *prefix="")
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
void set_global_io (SGIO *io)
SGIOget_global_io ()
void set_global_parallel (Parallel *parallel)
Parallelget_global_parallel ()
void set_global_version (Version *version)
Versionget_global_version ()
SGVector< char * > get_modelsel_names ()
char * get_modsel_param_descr (const char *param_name)
index_t get_modsel_param_index (const char *param_name)

Protected Attributes

T * array
int32_t array_size
bool free_array
const char * name
 DECLARE_ARRAY_STATISTICS

Additional Inherited Members

- Public Attributes inherited from CSGObject
SGIOio
Parallelparallel
Versionversion
Parameterm_parameters
Parameterm_model_selection_parameters
- Protected Member Functions inherited from CSGObject
virtual void load_serializable_pre () throw (ShogunException)
virtual void load_serializable_post () throw (ShogunException)
virtual void save_serializable_pre () throw (ShogunException)
virtual void save_serializable_post () throw (ShogunException)

Constructor & Destructor Documentation

CArray ( int32_t  initial_size = 1)

constructor

Parameters
initial_sizeinitial size of array

Definition at line 87 of file Array.h.

CArray ( T *  p_array,
int32_t  p_array_size,
bool  p_free_array = true,
bool  p_copy_array = false 
)

constructor

Parameters
p_arrayanother array
p_array_sizesize of another array
p_free_arrayif array must be freed
p_copy_arrayif array must be copied

Definition at line 103 of file Array.h.

CArray ( const T *  p_array,
int32_t  p_array_size 
)

constructor

Parameters
p_arrayanother array
p_array_sizesize of another array

Definition at line 116 of file Array.h.

virtual ~CArray ( )
virtual

Definition at line 123 of file Array.h.

Member Function Documentation

void clear_array ( )

clear the array (with zeros)

Definition at line 317 of file Array.h.

void display_array ( ) const
void display_size ( ) const
const T& element ( int32_t  idx1) const

get element at given index

Parameters
idx1index
Returns
element at given index

Definition at line 214 of file Array.h.

T& element ( int32_t  index)

get element at given index

Parameters
indexindex
Returns
element at given index

Definition at line 225 of file Array.h.

T& element ( T *  p_array,
int32_t  index 
)

get element of given array at given index

Parameters
p_arrayanother array
indexindex
Returns
element of given array at given index

Definition at line 240 of file Array.h.

T* get_array ( )

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

Returns
the array

Reimplemented in CArray3< T >, CArray3< float64_t >, CArray2< T >, CArray2< CPlifBase * >, CArray2< float64_t >, CArray2< float32_t >, and CArray2< int32_t >.

Definition at line 272 of file Array.h.

virtual const char* get_array_name ( ) const
virtual

get array name

Returns
name

Definition at line 140 of file Array.h.

int32_t get_array_size ( ) const

get array size (including granularity buffer)

Returns
total array size

Definition at line 155 of file Array.h.

int32_t get_dim1 ( )

get array size (including granularity buffer)

Returns
total array size

Reimplemented in CArray3< T >, CArray3< float64_t >, CArray2< T >, CArray2< CPlifBase * >, CArray2< float64_t >, CArray2< float32_t >, and CArray2< int32_t >.

Definition at line 164 of file Array.h.

const T& get_element ( int32_t  index) const

get array element at index

Parameters
indexindex
Returns
array element at index

Definition at line 188 of file Array.h.

virtual const char* get_name ( ) const
virtual

get name

Returns
name

Implements CSGObject.

Definition at line 134 of file Array.h.

CArray<T>& operator= ( const CArray< T > &  orig)

operator overload for array assignment

Parameters
origoriginal array
Returns
new array

Definition at line 355 of file Array.h.

const 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

Parameters
index
Returns
element at index

Definition at line 331 of file Array.h.

T& operator[] ( int32_t  index)

operator overload for array read only access

DOES NOT DO ANY BOUNDS CHECKING

Parameters
index
Returns
element at index

Definition at line 344 of file Array.h.

bool resize_array ( int32_t  n)

resize array

Parameters
nnew size
Returns
if resizing was successful

Definition at line 253 of file Array.h.

void set_array ( T *  p_array,
int32_t  p_array_size,
bool  p_free_array = true,
bool  copy_array = false 
)

set the array pointer and free previously allocated memory

Parameters
p_arrayanother array
p_array_sizesize of another array
p_free_arrayif array must be freed
copy_arrayif array must be copied

Definition at line 285 of file Array.h.

void set_array ( const T *  p_array,
int32_t  p_array_size 
)

set the array pointer and free previously allocated memory

Parameters
p_arrayanother array
p_array_sizesize of another array

Definition at line 306 of file Array.h.

void set_array_name ( const char *  p_name)

set name

Parameters
p_namenew name

Reimplemented in CArray2< T >, CArray2< CPlifBase * >, CArray2< float64_t >, CArray2< float32_t >, CArray2< int32_t >, CArray3< T >, and CArray3< float64_t >.

Definition at line 146 of file Array.h.

void set_const ( const_elem)

set array with a constant

Reimplemented in CArray3< T >, CArray3< float64_t >, CArray2< T >, CArray2< CPlifBase * >, CArray2< float64_t >, CArray2< float32_t >, and CArray2< int32_t >.

Definition at line 177 of file Array.h.

bool set_element ( const T &  p_element,
int32_t  index 
)

set array element at index 'index' return false in case of trouble

Parameters
p_elementarray element to set
indexindex
Returns
if setting was successful

Definition at line 201 of file Array.h.

void zero ( )

Member Data Documentation

T* array
protected

memory for dynamic array

Definition at line 381 of file Array.h.

int32_t array_size
protected

the number of potentially used elements in array

Definition at line 383 of file Array.h.

DECLARE_ARRAY_STATISTICS
protected

array statistics

Definition at line 389 of file Array.h.

bool free_array
protected

if array must be freed

Definition at line 385 of file Array.h.

const char* name
protected

array's name

Definition at line 387 of file Array.h.


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

SHOGUN Machine Learning Toolbox - Documentation