Dokumentation

vector< T > Class Template Reference

vector class influenced by standard library More...

#include <object/vector.h>

Classes

class  iterator
 vector iterator More...
 

Public Member Functions

 vector (T invalid=T())
 Constructor. More...
 
 vector (size_t count, T init, T invalid=T())
 Constructor with initial _capacity. More...
 
 vector (const vector &other)
 Copy constructor.
 
 ~vector ()
 Destructor.
 
T & at (size_t pos)
 access specified element More...
 
T & front ()
 Access the first element. More...
 
T & back ()
 Access the last element. More...
 
T * data ()
 direct access to the underlying array More...
 
bool empty () const
 Checks if the container has no element.
 
size_t size () const
 Get the number of elements. More...
 
size_t capacity () const
 Get the number of elements that can be held in currently allocated storage. More...
 
void clear ()
 Erases all elements from the container.
 
void reserve (size_t capacity)
 Increase the capacity of the vector. More...
 
void resize (size_t count, T value)
 Resizes the container. More...
 
void resize (size_t count)
 Resizes the container. More...
 
void push_back (const T &value)
 Adds an element to the end. More...
 
void insert (size_t pos, const T &value)
 Inserts elements at the specified location. More...
 
pop_back ()
 Remove the last element. More...
 
remove (size_t pos)
 Remove element at the specified location. More...
 
T & operator[] (int i)
 Access Element. More...
 
vector< T > & operator= (const vector< T > &other)
 Assignment. More...
 
vector< T > & operator+= (const vector< T > &other)
 Concatenate vector. More...
 
vector< T > & operator+= (const T &element)
 Concatenate element. More...
 
vector< T > operator+ (const vector< T > &other) const
 Concatenate two vectors. More...
 
vector< T > operator+ (const T &element) const
 Concatenate element. More...
 
vector< T >::iterator begin () const
 Iterator to beginning. More...
 
vector< T >::iterator end () const
 Iterator to end. More...
 

Detailed Description

template<class T>
class vector< T >

vector class influenced by standard library

Constructor & Destructor Documentation

template<class T >
vector< T >::vector ( invalid = T())
inlineexplicit

Constructor.

Parameters
invalidobject for invalid returns
template<class T >
vector< T >::vector ( size_t  count,
init,
invalid = T() 
)
inlineexplicit

Constructor with initial _capacity.

Parameters
countnumber of initial values
initinitial values
invalidobject for invalid returns

Member Function Documentation

template<class T >
T& vector< T >::at ( size_t  pos)
inline

access specified element

Parameters
posposition of the element to return
Returns
element or T() if out of bounds
Note
This function differs to the standard library due to the lack of exceptions
template<class T >
T& vector< T >::front ( )
inline

Access the first element.

Returns
first element or T() if none
template<class T >
T& vector< T >::back ( )
inline

Access the last element.

Returns
last element or T() if none
template<class T >
T* vector< T >::data ( )
inline

direct access to the underlying array

Returns
Pointer to data
template<class T >
size_t vector< T >::size ( ) const
inline

Get the number of elements.

Returns
number of entires
template<class T >
size_t vector< T >::capacity ( ) const
inline

Get the number of elements that can be held in currently allocated storage.

Returns
current capacity
template<class T >
void vector< T >::reserve ( size_t  capacity)
inline

Increase the capacity of the vector.

Parameters
capacitynew capacity
template<class T >
void vector< T >::resize ( size_t  count,
value 
)
inline

Resizes the container.

Parameters
countnew size of the container
valuethe value to initialize the new elements with
template<class T >
void vector< T >::resize ( size_t  count)
inline

Resizes the container.

Parameters
countnew size of the container
template<class T >
void vector< T >::push_back ( const T &  value)
inline

Adds an element to the end.

Parameters
valuethe value of the element to append
template<class T >
void vector< T >::insert ( size_t  pos,
const T &  value 
)
inline

Inserts elements at the specified location.

Parameters
posposition
valuevalue
template<class T >
T vector< T >::pop_back ( )
inline

Remove the last element.

Returns
last element
template<class T >
T vector< T >::remove ( size_t  pos)
inline

Remove element at the specified location.

Parameters
posposition
Returns
value or T() if position out of bounds
template<class T >
T& vector< T >::operator[] ( int  i)
inline

Access Element.

Parameters
iindex
template<class T >
vector<T>& vector< T >::operator= ( const vector< T > &  other)
inline

Assignment.

Parameters
other
template<class T >
vector<T>& vector< T >::operator+= ( const vector< T > &  other)
inline

Concatenate vector.

Parameters
othervector
Returns
reference to vector
template<class T >
vector<T>& vector< T >::operator+= ( const T &  element)
inline

Concatenate element.

Parameters
elementelement
Returns
reference to vector
template<class T >
vector<T> vector< T >::operator+ ( const vector< T > &  other) const
inline

Concatenate two vectors.

Parameters
othervector
Returns
new vector with all elements of this and other vector
template<class T >
vector<T> vector< T >::operator+ ( const T &  element) const
inline

Concatenate element.

Parameters
elementelement to Concatenate
Returns
new vector with all elements of this vector and element
template<class T >
vector<T>::iterator vector< T >::begin ( ) const
inline

Iterator to beginning.

Returns
Iterator pointing to the first element in the sequence
template<class T >
vector<T>::iterator vector< T >::end ( ) const
inline

Iterator to end.

Returns
Iterator pointing to the past-the-end element in the sequence

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