Friedrich-Alexander-Universität Erlangen-Nürnberg  /   Technische Fakultät  /   Department Informatik
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
 
vector< T >::iterator end () const
 

Detailed Description

template<class T>
class vector< T >

vector class influenced by standard library

Constructor & Destructor Documentation

◆ vector() [1/2]

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

Constructor.

Parameters
invalidobject for invalid returns

◆ vector() [2/2]

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

◆ at()

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

◆ front()

template<class T >
T& vector< T >::front ( )
inline

Access the first element.

Returns
first element or T() if none

◆ back()

template<class T >
T& vector< T >::back ( )
inline

Access the last element.

Returns
last element or T() if none

◆ data()

template<class T >
T* vector< T >::data ( )
inline

direct access to the underlying array

Returns
Pointer to data

◆ size()

template<class T >
size_t vector< T >::size ( ) const
inline

Get the number of elements.

Returns
number of entires

◆ capacity()

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

◆ reserve()

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

Increase the capacity of the vector.

Parameters
capacitynew capacity

◆ resize() [1/2]

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

◆ resize() [2/2]

template<class T >
void vector< T >::resize ( size_t  count)
inline

Resizes the container.

Parameters
countnew size of the container

◆ push_back()

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

◆ insert()

template<class T >
void vector< T >::insert ( size_t  pos,
const T &  value 
)
inline

Inserts elements at the specified location.

Parameters
posposition
valuevalue

◆ pop_back()

template<class T >
T vector< T >::pop_back ( )
inline

Remove the last element.

Returns
last element

◆ remove()

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

◆ operator[]()

template<class T >
T& vector< T >::operator[] ( int  i)
inline

Access Element.

Parameters
iindex

◆ operator=()

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

Assignment.

Parameters
other

◆ operator+=() [1/2]

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

Concatenate vector.

Parameters
othervector
Returns
reference to vector

◆ operator+=() [2/2]

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

Concatenate element.

Parameters
elementelement
Returns
reference to vector

◆ operator+() [1/2]

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

◆ operator+() [2/2]

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

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