CArray2< T > Class Template Reference


Detailed Description

template<class T>
class CArray2< T >

Template class Array2 implements a dense two dimensional array.

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

Definition at line 26 of file Array2.h.

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

List of all members.

Public Member Functions

 CArray2 (int32_t dim1, int32_t dim2)
 CArray2 (T *p_array, int32_t dim1, int32_t dim2, bool p_free_array=true, bool p_copy_array=false)
 CArray2 (const T *p_array, int32_t dim1, int32_t dim2)
virtual ~CArray2 ()
void get_array_size (int32_t &dim1, int32_t &dim2)
int32_t get_dim1 ()
int32_t get_dim2 ()
void zero ()
T * get_array ()
void set_name (const char *p_name)
void set_array (T *p_array, int32_t dim1, int32_t dim2, bool p_free_array=true, bool copy_array=false)
bool resize_array (int32_t dim1, int32_t dim2)
const T & get_element (int32_t idx1, int32_t idx2) const
bool set_element (const T &p_element, int32_t idx1, int32_t idx2)
const T & element (int32_t idx1, int32_t idx2) const
T & element (int32_t idx1, int32_t idx2)
T & element (T *p_array, int32_t idx1, int32_t idx2)
T & element (T *p_array, int32_t idx1, int32_t idx2, int32_t p_dim1_size)
CArray2< T > & operator= (CArray2< T > &orig)
void display_array () const
void display_size () const
virtual const char * get_name ()

Protected Attributes

int32_t dim1_size
int32_t dim2_size

Constructor & Destructor Documentation

template<class T>
CArray2< T >::CArray2 ( int32_t  dim1,
int32_t  dim2 
)

constructor

Parameters:
dim1 dimension 1
dim2 dimension 2

Definition at line 34 of file Array2.h.

template<class T>
CArray2< T >::CArray2 ( T *  p_array,
int32_t  dim1,
int32_t  dim2,
bool  p_free_array = true,
bool  p_copy_array = false 
)

constructor

Parameters:
p_array another array
dim1 dimension 1
dim2 dimension 2
p_free_array if array must be freed
p_copy_array if array must be copied

Definition at line 47 of file Array2.h.

template<class T>
CArray2< T >::CArray2 ( const T *  p_array,
int32_t  dim1,
int32_t  dim2 
)

constructor

Parameters:
p_array another array
dim1 dimension 1
dim2 dimension 2

Definition at line 59 of file Array2.h.

template<class T>
virtual CArray2< T >::~CArray2 (  )  [virtual]

Definition at line 64 of file Array2.h.


Member Function Documentation

template<class T>
void CArray2< T >::display_array (  )  const

display array

Reimplemented from CArray< T >.

Definition at line 235 of file Array2.h.

template<class T>
void CArray2< T >::display_size (  )  const

display array size

Reimplemented from CArray< T >.

Definition at line 251 of file Array2.h.

template<class T>
T& CArray2< T >::element ( T *  p_array,
int32_t  idx1,
int32_t  idx2,
int32_t  p_dim1_size 
)

get element of given array at given index

Parameters:
p_array another array
idx1 index 1
idx2 index 2
p_dim1_size size of dimension 1
Returns:
element of given array at given index

Definition at line 212 of file Array2.h.

template<class T>
T& CArray2< T >::element ( T *  p_array,
int32_t  idx1,
int32_t  idx2 
)

get element of given array at given index

Parameters:
p_array another array
idx1 index 1
idx2 index 2
Returns:
element of given array at given index

Definition at line 196 of file Array2.h.

template<class T>
T& CArray2< T >::element ( int32_t  idx1,
int32_t  idx2 
)

get array element at index

Parameters:
idx1 index 1
idx2 index 2
Returns:
array element at index

Definition at line 182 of file Array2.h.

template<class T>
const T& CArray2< T >::element ( int32_t  idx1,
int32_t  idx2 
) const

get array element at index

Parameters:
idx1 index 1
idx2 index 2
Returns:
array element at index

Definition at line 171 of file Array2.h.

template<class T>
T* CArray2< T >::get_array (  ) 

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 !

Returns:
the array

Reimplemented from CArray< T >.

Definition at line 99 of file Array2.h.

template<class T>
void CArray2< T >::get_array_size ( int32_t &  dim1,
int32_t &  dim2 
)

return total array size (including granularity buffer)

Parameters:
dim1 dimension 1 will be stored here
dim2 dimension 2 will be stored here

Definition at line 71 of file Array2.h.

template<class T>
int32_t CArray2< T >::get_dim1 (  ) 

get dimension 1

Returns:
dimension 1

Reimplemented from CArray< T >.

Definition at line 81 of file Array2.h.

template<class T>
int32_t CArray2< T >::get_dim2 (  ) 

get dimension 2

Returns:
dimension 2

Definition at line 87 of file Array2.h.

template<class T>
const T& CArray2< T >::get_element ( int32_t  idx1,
int32_t  idx2 
) const

get array element at index

Parameters:
idx1 index 1
idx2 index 2
Returns:
array element at index

Definition at line 144 of file Array2.h.

template<class T>
virtual const char* CArray2< T >::get_name (  )  [virtual]
Returns:
object name

Reimplemented from CArray< T >.

Definition at line 257 of file Array2.h.

template<class T>
CArray2<T>& CArray2< T >::operator= ( CArray2< T > &  orig  ) 

operator overload for array assignment

Parameters:
orig original array
Returns:
new array

Definition at line 226 of file Array2.h.

template<class T>
bool CArray2< T >::resize_array ( int32_t  dim1,
int32_t  dim2 
)

resize array

Parameters:
dim1 new dimension 1
dim2 new dimension 2
Returns:
if resizing was successful

Definition at line 131 of file Array2.h.

template<class T>
void CArray2< T >::set_array ( T *  p_array,
int32_t  dim1,
int32_t  dim2,
bool  p_free_array = true,
bool  copy_array = false 
)

set the array pointer and free previously allocated memory

Parameters:
p_array another array
dim1 dimension 1
dim2 dimensino 2
p_free_array if array must be freed
copy_array if array must be copied

Definition at line 118 of file Array2.h.

template<class T>
bool CArray2< T >::set_element ( const T &  p_element,
int32_t  idx1,
int32_t  idx2 
)

set array element at index 'index'

Parameters:
p_element array element
idx1 index 1
idx2 index 2
Returns:
if setting was successful

Definition at line 158 of file Array2.h.

template<class T>
void CArray2< T >::set_name ( const char *  p_name  ) 

set array's name

Parameters:
p_name new name

Reimplemented from CArray< T >.

Definition at line 105 of file Array2.h.

template<class T>
void CArray2< T >::zero (  ) 

zero array

Reimplemented from CArray< T >.

Definition at line 90 of file Array2.h.


Member Data Documentation

template<class T>
int32_t CArray2< T >::dim1_size [protected]

size of array's dimension 1

Definition at line 261 of file Array2.h.

template<class T>
int32_t CArray2< T >::dim2_size [protected]

size of array's dimension 2

Definition at line 263 of file Array2.h.


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

SHOGUN Machine Learning Toolbox - Documentation