Dune::ReservedVector< T, n > Class Template Reference

A Vector class with statically reserved memory. More...

#include <dune/common/reservedvector.hh>

List of all members.

Public Types

typedef T value_type
 The type of object, T, stored in the vector.
typedef T * pointer
 Pointer to T.
typedef T & reference
 Reference to T.
typedef const T & const_reference
 Const reference to T.
typedef size_t size_type
 An unsigned integral type.
typedef std::ptrdiff_t difference_type
 A signed integral type.
typedef Dune::GenericIterator
< ReservedVector, value_type
iterator
 Iterator used to iterate through a vector.
typedef Dune::GenericIterator
< const ReservedVector, const
value_type
const_iterator
 Const iterator used to iterate through a vector.

Public Member Functions

 ReservedVector ()
 Constructor.

void clear ()
 Erases all elements.
void resize (size_t s)
 Specifies a new size for the vector.
void push_back (const T &t)
 Appends an element to the end of a vector, up to the maximum size n, O(1) time.
void pop_back ()
 Erases the last element of the vector, O(1) time.
iterator begin ()
 Returns a iterator pointing to the beginning of the vector.
const_iterator begin () const
 Returns a const_iterator pointing to the beginning of the vector.
iterator end ()
 Returns an iterator pointing to the end of the vector.
const_iterator end () const
 Returns a const_iterator pointing to the end of the vector.
reference operator[] (size_type i)
 Returns reference to the i'th element.
const_reference operator[] (size_type i) const
 Returns a const reference to the i'th element.
reference front ()
 Returns reference to first element of vector.
const_reference front () const
 Returns const reference to first element of vector.
reference back ()
 Returns reference to last element of vector.
const_reference back () const
 Returns const reference to last element of vector.

Friends

std::ostream & operator<< (std::ostream &s, const ReservedVector &v)
 Send ReservedVector to an output stream.



size_type size () const
 Returns number of elements in the vector.
bool empty () const
 Returns true if vector has no elements.
static size_type capacity ()
 Returns current capacity (allocated memory) of the vector.
static size_type max_size ()
 Returns the maximum length of the vector.

Detailed Description

template<class T, int n>
class Dune::ReservedVector< T, n >

A Vector class with statically reserved memory.

ReservedVector is something between Dune::array and std::vector. You have vector which can be extended and shrunk using methods like push_back and pop_back, but reserved memory is predefined.

This implies that the vector can not grow bigger than the predefined maximum size.

Template Parameters:
T The data type ReservedVector stores.
n The maximum number of objects the ReservedVector can store.

Member Typedef Documentation

template<class T , int n>
typedef Dune::GenericIterator<const ReservedVector, const value_type> Dune::ReservedVector< T, n >::const_iterator

Const iterator used to iterate through a vector.

template<class T , int n>
typedef const T& Dune::ReservedVector< T, n >::const_reference

Const reference to T.

template<class T , int n>
typedef std::ptrdiff_t Dune::ReservedVector< T, n >::difference_type

A signed integral type.

template<class T , int n>
typedef Dune::GenericIterator<ReservedVector, value_type> Dune::ReservedVector< T, n >::iterator

Iterator used to iterate through a vector.

template<class T , int n>
typedef T* Dune::ReservedVector< T, n >::pointer

Pointer to T.

template<class T , int n>
typedef T& Dune::ReservedVector< T, n >::reference

Reference to T.

template<class T , int n>
typedef size_t Dune::ReservedVector< T, n >::size_type

An unsigned integral type.

template<class T , int n>
typedef T Dune::ReservedVector< T, n >::value_type

The type of object, T, stored in the vector.

Typedefs


Constructor & Destructor Documentation

template<class T , int n>
Dune::ReservedVector< T, n >::ReservedVector (  )  [inline]

Constructor.

Constructors


Member Function Documentation

template<class T , int n>
reference Dune::ReservedVector< T, n >::back (  )  [inline]

Returns reference to last element of vector.

References CHECKSIZE.

template<class T , int n>
const_reference Dune::ReservedVector< T, n >::back (  )  const [inline]

Returns const reference to last element of vector.

References CHECKSIZE.

template<class T , int n>
const_iterator Dune::ReservedVector< T, n >::begin (  )  const [inline]

Returns a const_iterator pointing to the beginning of the vector.

template<class T , int n>
iterator Dune::ReservedVector< T, n >::begin (  )  [inline]

Returns a iterator pointing to the beginning of the vector.

template<class T , int n>
static size_type Dune::ReservedVector< T, n >::capacity (  )  [inline, static]

Returns current capacity (allocated memory) of the vector.

template<class T , int n>
void Dune::ReservedVector< T, n >::clear (  )  [inline]

Erases all elements.

Data access operations

template<class T , int n>
bool Dune::ReservedVector< T, n >::empty (  )  const [inline]

Returns true if vector has no elements.

Referenced by Dune::ReservedVector< T, n >::pop_back().

template<class T , int n>
const_iterator Dune::ReservedVector< T, n >::end (  )  const [inline]

Returns a const_iterator pointing to the end of the vector.

template<class T , int n>
iterator Dune::ReservedVector< T, n >::end (  )  [inline]

Returns an iterator pointing to the end of the vector.

template<class T , int n>
reference Dune::ReservedVector< T, n >::front (  )  [inline]

Returns reference to first element of vector.

References CHECKSIZE.

template<class T , int n>
const_reference Dune::ReservedVector< T, n >::front (  )  const [inline]

Returns const reference to first element of vector.

References CHECKSIZE.

template<class T , int n>
static size_type Dune::ReservedVector< T, n >::max_size (  )  [inline, static]

Returns the maximum length of the vector.

template<class T , int n>
reference Dune::ReservedVector< T, n >::operator[] ( size_type  i  )  [inline]

Returns reference to the i'th element.

References CHECKSIZE.

template<class T , int n>
const_reference Dune::ReservedVector< T, n >::operator[] ( size_type  i  )  const [inline]

Returns a const reference to the i'th element.

References CHECKSIZE.

template<class T , int n>
void Dune::ReservedVector< T, n >::pop_back (  )  [inline]

Erases the last element of the vector, O(1) time.

References Dune::ReservedVector< T, n >::empty().

template<class T , int n>
void Dune::ReservedVector< T, n >::push_back ( const T &  t  )  [inline]

Appends an element to the end of a vector, up to the maximum size n, O(1) time.

References CHECKSIZE.

template<class T , int n>
void Dune::ReservedVector< T, n >::resize ( size_t  s  )  [inline]

Specifies a new size for the vector.

References CHECKSIZE.

template<class T , int n>
size_type Dune::ReservedVector< T, n >::size (  )  const [inline]

Returns number of elements in the vector.

Informative Methods


Friends And Related Function Documentation

template<class T , int n>
std::ostream& operator<< ( std::ostream &  s,
const ReservedVector< T, n > &  v 
) [friend]

Send ReservedVector to an output stream.


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

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].