ApparatusFramework::vector< T, maxSize > Class Template Reference
[RT-STL]

#include <RT_STL/current/include/vector.h>

List of all members.

Classes

class  iterator

Public Types

typedef T value_type
typedef int size_type
typedef int difference_type

Public Member Functions

 vector ()
 vector (int n, const T &val=T())
 vector (const vector &lvalue)
 vector (iterator first, iterator last)
 ~vector ()
T & operator[] (int n)
T & at (int n)
T & front ()
T & back ()
void push_back (const T &val)
void pop_back ()
void insert (iterator pos, const T &val)
void remove (const T &val)
void clear ()
void erase (const iterator pos)
void assign (const iterator first, const iterator last)
iterator begin () const
iterator end () const
bool empty () const
int size () const

Friends

class iterator

Detailed Description

template<class T, int maxSize>
class ApparatusFramework::vector< T, maxSize >

The vector class implements the equivalent of the vector class defined in the standard template library. But our class does not use any dynamic memory allocation scheme. Therefore the additional template parameter maxSize defines the maximum number of elements the vector can ever contain. On the other hand, we do not support allocators.

We support the same interface as the STL class. This feature allows an easy switch between the dynamic and the static bound vector class.

The front of the vector is at the position 0 if the vector contains n items. The back of the vector is always at the position n. Our vector is implemented using a simple array. Therefore the operations manipulating the back are very efficient. The vector class support only query operations on the front. These operations are also very efficient.

Definition at line 71 of file vector.h.


Member Typedef Documentation

template<class T , int maxSize>
typedef int ApparatusFramework::vector< T, maxSize >::difference_type

The type for difference information.

Definition at line 91 of file vector.h.

template<class T , int maxSize>
typedef int ApparatusFramework::vector< T, maxSize >::size_type

The type for size information.

Definition at line 87 of file vector.h.

template<class T , int maxSize>
typedef T ApparatusFramework::vector< T, maxSize >::value_type

The type of an entry into this vector.

Definition at line 83 of file vector.h.


Constructor & Destructor Documentation

template<class T , int maxSize>
ApparatusFramework::vector< T, maxSize >::vector (  )  [inline, explicit]

constructors, destructors Constructs a new vector object.

Definition at line 379 of file vector.h.

template<class T , int maxSize>
ApparatusFramework::vector< T, maxSize >::vector ( int  n,
const T &  val = T() 
) [inline, explicit]

Constructs a new vector object containing a repetition of n elements of value v.

Parameters:
n number of elements.
val initial value.

Definition at line 384 of file vector.h.

template<class T , int maxSize>
ApparatusFramework::vector< T, maxSize >::vector ( const vector< T, maxSize > &  lvalue  )  [inline]

The copy constructor constructs a new vector object from an existing one.

Parameters:
lvalue vector used to generate a new object.

Definition at line 393 of file vector.h.

template<class T , int maxSize>
ApparatusFramework::vector< T, maxSize >::vector ( iterator  first,
iterator  last 
) [inline]

Constructs a new vector object containing a sequence.

Parameters:
first first element of the sequence.
last last element of the sequence.

Definition at line 402 of file vector.h.

template<class T , int maxSize>
ApparatusFramework::vector< T, maxSize >::~vector (  )  [inline]

Destroys the object and releases all the associated resources.

Definition at line 411 of file vector.h.


Member Function Documentation

template<class T , int maxSize>
void ApparatusFramework::vector< T, maxSize >::assign ( const iterator  first,
const iterator  last 
) [inline]

Replaces the sequence controlled by this object with the sequence [first, last).

Parameters:
first iterator where the assigned sequence starts (first element).
last points to the last element of the squence to assign.

Definition at line 512 of file vector.h.

template<class T , int maxSize>
T & ApparatusFramework::vector< T, maxSize >::at ( int  n  )  [inline]

Returns the item at the given position. A sanity check is performed.

Parameters:
n index of the requested item. The index starts at 0.
Returns:
T& reference to the item at the given position.

Definition at line 446 of file vector.h.

template<class T , int maxSize>
T & ApparatusFramework::vector< T, maxSize >::back (  )  [inline]

Returns the object stored at the front of the vector. If the vector is empty, the result is undefined.

Returns:
T& reference to the item at the given position.

Definition at line 460 of file vector.h.

template<class T , int maxSize>
vector< T, maxSize >::iterator ApparatusFramework::vector< T, maxSize >::begin (  )  const [inline]

queries Returns an iterator pointing at the beginning of the container.

Returns:
iterator iterator to the beginning of the container.

Definition at line 415 of file vector.h.

Referenced by ApparatusFramework::vector< T, maxSize >::remove().

template<class T , int maxSize>
void ApparatusFramework::vector< T, maxSize >::clear (  )  [inline]

Clears the whole content of the content.

Definition at line 522 of file vector.h.

template<class T , int maxSize>
bool ApparatusFramework::vector< T, maxSize >::empty (  )  const [inline]

True if the container is empty, false otherwise.

Returns:
bool result of the query.

Definition at line 550 of file vector.h.

template<class T , int maxSize>
vector< T, maxSize >::iterator ApparatusFramework::vector< T, maxSize >::end (  )  const [inline]

Returns an iterator pointing at the end of the container.

Returns:
iterator iterator to the end of the container.

Definition at line 430 of file vector.h.

Referenced by ApparatusFramework::vector< T, maxSize >::remove().

template<class T , int maxSize>
void ApparatusFramework::vector< T, maxSize >::erase ( const iterator  pos  )  [inline]

Removes the item at the position shown by the iterator.

Parameters:
pos iterator showing which item should be removed.

Definition at line 528 of file vector.h.

Referenced by ApparatusFramework::vector< T, maxSize >::remove().

template<class T , int maxSize>
T & ApparatusFramework::vector< T, maxSize >::front (  )  [inline]

Returns the object stored at the front of the vector.

Returns:
T& reference to the item at the given position.

Definition at line 453 of file vector.h.

template<class T , int maxSize>
void ApparatusFramework::vector< T, maxSize >::insert ( iterator  pos,
const T &  val 
) [inline]

Inserts the given item at the given position. If the vector is empty, the result is undefined.

Parameters:
pos iterator indicating where the item should be inserted. We insert at this position meaning before the item at this position.
val item to be inserted.

Definition at line 482 of file vector.h.

template<class T , int maxSize>
T & ApparatusFramework::vector< T, maxSize >::operator[] ( int  n  )  [inline]

modifiers Returns the item at the given position. No sanity checks are performed.

Parameters:
n index of the requested item. The index starts at 0.
Returns:
T& reference to the item at the given position.

Definition at line 440 of file vector.h.

template<class T , int maxSize>
void ApparatusFramework::vector< T, maxSize >::pop_back (  )  [inline]

Removes the item at the back of the container. If the vector is empty, the result is undefined.

Definition at line 475 of file vector.h.

template<class T , int maxSize>
void ApparatusFramework::vector< T, maxSize >::push_back ( const T &  val  )  [inline]

Pushes the given item at the back of the container.

Parameters:
val item to be inserted at the back of the container.

Definition at line 467 of file vector.h.

template<class T , int maxSize>
void ApparatusFramework::vector< T, maxSize >::remove ( const T &  val  )  [inline]

Removes the given item if it is part of the container. If not found nothing is done.

Parameters:
val item be removed from the container.

Definition at line 498 of file vector.h.

References ApparatusFramework::vector< T, maxSize >::begin(), ApparatusFramework::vector< T, maxSize >::end(), and ApparatusFramework::vector< T, maxSize >::erase().

template<class T , int maxSize>
int ApparatusFramework::vector< T, maxSize >::size (  )  const [inline]

Returns the size of the container.

Returns:
int size of the containter.

Definition at line 544 of file vector.h.


Friends And Related Function Documentation

template<class T , int maxSize>
friend class iterator [friend]

Make friends with our iterator type.

Definition at line 75 of file vector.h.

© 2004-2010 bbv Software Services AG / Apparatus Services