Kalman::KVector< T, BEG, DBG > Class Template Reference

Minimalist vector template class. More...

#include <kvector.hpp>

List of all members.

Public Types

typedef T type
 Type of objects contained in the vector.
enum  { beg = BEG }

Public Member Functions

void resize (K_UINT_32 n)
 Resizes the vector. Resulting vector contents are undefined.
KVectoroperator= (const T &a)
 Assigns a copy of a to all elements of the vector.
KVectoroperator= (const KVector &v)
 Copy assignment operator. Performs a deep copy.
void assign (K_UINT_32 n, const T *v)
 Copies an array of n instances of T.
void swap (KVector &v)
 Constant-time swap function between two vectors.
Constructors and destructor.
 KVector ()
 Default constructor. Creates an empty vector.
 KVector (K_UINT_32 n)
 Creates a vector of n default instances of T.
 KVector (K_UINT_32 n, const T &a)
 Creates a vector of n copies of a.
 KVector (K_UINT_32 n, const T *v)
 Creates a vector from an array of n instances of T.
 KVector (const KVector &v)
 Copy constructor. Performs a deep copy.
 ~KVector ()
 Destructor.
Member access functions.
T & operator() (K_UINT_32 i)
 Returns the i'th element.
const T & operator() (K_UINT_32 i) const
 Returns the i'th element, const version.
K_UINT_32 size () const
 Returns the vector size.
Streaming functions
void get (std::istream &is)
 Reads a vector from a stream.
void put (std::ostream &os) const
 Writes a vector to a stream.


Detailed Description

template<typename T, K_UINT_32 BEG, bool DBG>
class Kalman::KVector< T, BEG, DBG >

Minimalist vector template class.

This vector class does not define any fancy linear algebra functions, nor even any operator between vectors. Its sole purpose is to well encapsulate an extensible array representing a vector, and also to allow starting index to be 0 or 1.

Template parameters
Type requirements for T
This means that, if t1, t2 are instances of T, is is of type istream and os is of type ostream, the following expressions must be valid : -
 T(); T t1; 
Default constructor -
 T t1 = t2; T t1(t2); T(t1); 
Copy constructor -
 t1 = t2; 
Assignment operator -
 is >> t1; 
operator>>() -
 os << t1; 
operator<<() Finally, note that operator>>() and operator<<() must be compatible. Also, operator&() must not have been overloaded.


Member Enumeration Documentation

template<typename T, K_UINT_32 BEG, bool DBG>
anonymous enum
 

Enumerator:
beg  Starting index of vector, either 0 or 1.


Constructor & Destructor Documentation

template<typename T, K_UINT_32 BEG, bool DBG>
Kalman::KVector< T, BEG, DBG >::KVector K_UINT_32  n  )  [inline, explicit]
 

Creates a vector of n default instances of T.

Parameters:
n Number of elements in vector. Can be 0.

template<typename T, K_UINT_32 BEG, bool DBG>
Kalman::KVector< T, BEG, DBG >::KVector K_UINT_32  n,
const T &  a
[inline]
 

Creates a vector of n copies of a.

Parameters:
n Number of elements in vector. Can be 0.
a Value to copy multiple times in the vector.

template<typename T, K_UINT_32 BEG, bool DBG>
Kalman::KVector< T, BEG, DBG >::KVector K_UINT_32  n,
const T *  v
[inline]
 

Creates a vector from an array of n instances of T.

This function allows to transform a C-style array of T objects in a KVector<T, BEG, DBG> equivalent array. Note that objects from the C-style array are copied into the vector, which may slow down application if used extensively.

Parameters:
n Size of the v array. Can be 0.
v Pointer to an n-size array of T objects.

template<typename T, K_UINT_32 BEG, bool DBG>
Kalman::KVector< T, BEG, DBG >::KVector const KVector< T, BEG, DBG > &  v  )  [inline]
 

Copy constructor. Performs a deep copy.

Parameters:
v Vector to copy. Can be an empty vector.


Member Function Documentation

template<typename T, K_UINT_32 BEG, bool DBG>
T & Kalman::KVector< T, BEG, DBG >::operator() K_UINT_32  i  )  [inline]
 

Returns the i'th element.

Parameters:
i Index of element to retrieve from vector.
Returns:
A reference to the i'th element.
Exceptions:
OutOfBoundError Thrown if i is out of vector bounds and DBG == true.

template<typename T, K_UINT_32 BEG, bool DBG>
const T & Kalman::KVector< T, BEG, DBG >::operator() K_UINT_32  i  )  const [inline]
 

Returns the i'th element, const version.

Parameters:
i Index of element to retrieve from vector.
Returns:
A const reference to the i'th element.
Exceptions:
OutOfBoundError Thrown if i is out of vector bounds and DBG == true.

template<typename T, K_UINT_32 BEG, bool DBG>
K_UINT_32 Kalman::KVector< T, BEG, DBG >::size  )  const [inline]
 

Returns the vector size.

Returns:
The number of elements in the vector.

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KVector< T, BEG, DBG >::resize K_UINT_32  n  )  [inline]
 

Resizes the vector. Resulting vector contents are undefined.

Parameters:
n The new size of the vector. Can be 0.
Warning:
This function may invalidates pointers inside the vector.
Note:
Resizing to a smaller size does not free any memory. To do so, one can swap the vector to shrink with a temporary copy of itself : KVector<T, BEG, DBG>(v).swap(v).

template<typename T, K_UINT_32 BEG, bool DBG>
KVector< T, BEG, DBG > & Kalman::KVector< T, BEG, DBG >::operator= const T &  a  )  [inline]
 

Assigns a copy of a to all elements of the vector.

Parameters:
a Instance to copy to each element of vector.
Returns:
A reference to the vector.

template<typename T, K_UINT_32 BEG, bool DBG>
KVector< T, BEG, DBG > & Kalman::KVector< T, BEG, DBG >::operator= const KVector< T, BEG, DBG > &  v  )  [inline]
 

Copy assignment operator. Performs a deep copy.

Parameters:
v Vector to copy.
Returns:
A reference to the assigned vector.
Warning:
This function invalidates pointers inside the vector.

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KVector< T, BEG, DBG >::assign K_UINT_32  n,
const T *  v
[inline]
 

Copies an array of n instances of T.

Parameters:
n Size of C-style array.
v Pointer to first element to copy from C-style array.
Warning:
This function invalidates pointers inside the vector.

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KVector< T, BEG, DBG >::swap KVector< T, BEG, DBG > &  v  )  [inline]
 

Constant-time swap function between two vectors.

This function is fast, since it exchanges pointers to underlying implementation without copying any element.

Parameters:
v Vector to swap.
Note:
No pointer is invalidated by this function. They still point to the same element, but in the other vector.

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KVector< T, BEG, DBG >::get std::istream &  is  )  [inline]
 

Reads a vector from a stream.

This function will extract size() elements from a stream to fill the vector, while considering the formatting constraints of the current vector printing context.

Parameters:
is A reference to the input stream.
See also:
createKVectorContext()

selectKVectorContext()

template<typename T, K_UINT_32 BEG, bool DBG>
void Kalman::KVector< T, BEG, DBG >::put std::ostream &  os  )  const [inline]
 

Writes a vector to a stream.

This function will send all the vector elements to a stream, while considering the formatting constraints of the current vector printing context.

Parameters:
os A reference to the output stream.
See also:
createKVectorContext()

selectKVectorContext()


The documentation for this class was generated from the following files:
Generated on Sat Jan 28 21:02:01 2006 for KFilter by  doxygen 1.4.5