Public Member Functions | Public Attributes

v_array< T > Class Template Reference


Detailed Description

template<class T>
class shogun::v_array< T >

Class v_array is a templated class used to store variable length arrays. Memory locations are stored as 'extents', i.e., address of the first memory location and address after the last member.

`begin', `end' and `end_array' handle the extent of the array. `end_array' is the address at the end of the space allocated for the array while `end' is the address at the end of the space actually filled with elements.

The class should be instantiated on the basis of the data type of the contained array, eg. v_array<float32_t> if one wants to store a float32_t* array.

Definition at line 39 of file v_array.h.

List of all members.

Public Member Functions

 v_array ()
T & operator[] (unsigned int i)
last ()
pop ()
bool empty ()
void decr ()
unsigned int index ()
void erase ()
void push (const T &new_elem)
void push_many (const T *new_elem, size_t num)
void reserve (size_t length)
void calloc_reserve (size_t length)
v_array< T > pop (v_array< v_array< T > > &stack)

Public Attributes

T * begin
 Pointer to first element of the array.
T * end
 Pointer to last set element in the array.
T * end_array
 Pointer to end of array, based on memory reserved.

Constructor & Destructor Documentation

v_array (  ) 

Constructor. Sets begin and end pointers to NULL.

Definition at line 47 of file v_array.h.


Member Function Documentation

void calloc_reserve ( size_t  length  ) 

Reserve space for specified number of elements. No reallocation is done, array is replaced.

Parameters:
length 

Definition at line 200 of file v_array.h.

void decr (  ) 

Decrement the 'end' pointer.

Definition at line 89 of file v_array.h.

bool empty (  ) 

Check if array is empty or not.

Returns:
whether array is empty

Definition at line 83 of file v_array.h.

void erase (  ) 

Empty the array.

Definition at line 102 of file v_array.h.

unsigned int index (  ) 

Get number of elements in array.

Returns:
number of array elements

Definition at line 96 of file v_array.h.

T last (  ) 

Return the last element.

Returns:
Last element of array

Definition at line 69 of file v_array.h.

T& operator[] ( unsigned int  i  ) 

Operator [] overloaded to return the i-th element of the stored array.

Parameters:
i index of the element, starting at 0
Returns:
element at position i

Definition at line 62 of file v_array.h.

v_array< T > pop ( v_array< v_array< T > > &  stack  ) 

Pop an array from a list of arrays.

Parameters:
stack array of arrays
Returns:
popped array

Definition at line 208 of file v_array.h.

T pop (  ) 

Pop from the array.

Returns:
Popped element

Definition at line 76 of file v_array.h.

void push ( const T &  new_elem  ) 

Push an element into the array.

Parameters:
new_elem element to be pushed

Definition at line 157 of file v_array.h.

void push_many ( const T *  new_elem,
size_t  num 
)

Push multiple elements into the array.

Parameters:
new_elem pointer to first element
num number of elements

Definition at line 172 of file v_array.h.

void reserve ( size_t  length  ) 

Reserve space for specified number of elements. Reallocate, keeping the elements currently in the array.

Parameters:
length number of elements to accommodate

Definition at line 188 of file v_array.h.


Member Data Documentation

T* begin

Pointer to first element of the array.

Definition at line 146 of file v_array.h.

T* end

Pointer to last set element in the array.

Definition at line 149 of file v_array.h.

Pointer to end of array, based on memory reserved.

Definition at line 152 of file v_array.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation