Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

base::array_t< T > Class Template Reference

This defines a simple array template that will work on scalar types only. More...

#include <array_t.h>

Inheritance diagram for base::array_t< T >:

base::pointer_t< T > List of all members.

Public Types

enum  { INC = 8 }
 increase size step: at least 1 More...

Public Member Functions

 array_t (size_t initSize=4)
 constructor: alloc and init the array to 0 always at least 1 element.
 ~array_t ()
 destructor: free the array
 array_t (const array_t< T > &arr)
 Copy constructor.
array_toperator= (array_t< T > &arr)
 copy operator
get (size_t at) const
 data read: test if outside bounds
void set (size_t at, T value)
 data write: may increase array
replace (size_t at, T value)
 data read/write: may increase array
void add (size_t at, T value)
 addition with the given argument

Private Member Functions

void ensurePos (size_t at)
 make sure position at may be accessed

Detailed Description

template<class T>
class base::array_t< T >

This defines a simple array template that will work on scalar types only.

The idea is to be able to access the array randomly even on non predefined position. The array will grow automatically. This is not possible with std::vector: you have to define a loop and use push_back() to fill the gaps. Besides, reading outside the vector will seg-fault.

Lower case name: basic template on basic scalar types only this class is not supposed to have sub-classes


Member Enumeration Documentation

template<class T>
anonymous enum
 

increase size step: at least 1

Enumeration values:
INC 


Constructor & Destructor Documentation

template<class T>
base::array_t< T >::array_t size_t  initSize = 4  )  [inline]
 

constructor: alloc and init the array to 0 always at least 1 element.

Parameters:
initSize,: initial size

template<class T>
base::array_t< T >::~array_t  )  [inline]
 

destructor: free the array

template<class T>
base::array_t< T >::array_t const array_t< T > &  arr  )  [inline]
 

Copy constructor.


Member Function Documentation

template<class T>
void base::array_t< T >::add size_t  at,
value
[inline]
 

addition with the given argument

Parameters:
at,: where to add value
value,: what to add

template<class T>
void base::array_t< T >::ensurePos size_t  at  )  [inline, private]
 

make sure position at may be accessed

Parameters:
at,: position to be able to read.
Postcondition:
data[at] is valid.

template<class T>
T base::array_t< T >::get size_t  at  )  const [inline]
 

data read: test if outside bounds

Parameters:
at,: where to read. if at is outside limits then return 0.

template<class T>
array_t& base::array_t< T >::operator= array_t< T > &  arr  )  [inline]
 

copy operator

template<class T>
T base::array_t< T >::replace size_t  at,
value
[inline]
 

data read/write: may increase array

Parameters:
at,: where to read and write.
value,: what to write.
Returns:
original value at position at.

template<class T>
void base::array_t< T >::set size_t  at,
value
[inline]
 

data write: may increase array

Parameters:
at,: where to write.
value,: what to write. if at is outside limits then the array is increased.


The documentation for this class was generated from the following file:
Generated on Fri Jun 30 00:02:30 2006 for Module base by  doxygen 1.4.2