dune-functions 2.9.0
Friends | List of all members
Dune::Functions::ReservedDeque< T, n > Class Template Reference

A double-ended queue (deque) class with statically reserved memory. More...

#include <dune/functions/common/reserveddeque.hh>

Public Types

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

Public Member Functions

 ReservedDeque ()
 Constructor. More...
 
 ReservedDeque (std::initializer_list< T > const &l)
 
void clear ()
 Erases all elements. More...
 
void resize (size_t s)
 Specifies a new size for the vector. More...
 
void push_back (const T &t)
 Appends an element to the end of a vector, up to the maximum size n, O(1) time. More...
 
void push_front (const T &t)
 Prepends an element to the begin of a deque if size<capacity, O(1) time. More...
 
void pop_back ()
 Erases the last element of the vector, O(1) time. More...
 
void pop_front ()
 Erases the first element of the vector, O(1) time. More...
 
iterator begin ()
 Returns a iterator pointing to the beginning of the vector. More...
 
const_iterator begin () const
 Returns a const_iterator pointing to the beginning of the vector. More...
 
iterator end ()
 Returns an iterator pointing to the end of the vector. More...
 
const_iterator end () const
 Returns a const_iterator pointing to the end of the vector. More...
 
reference operator[] (size_type i)
 Returns reference to the i'th element. More...
 
const_reference operator[] (size_type i) const
 Returns a const reference to the i'th element. More...
 
reference front ()
 Returns reference to first element of vector. More...
 
const_reference front () const
 Returns const reference to first element of vector. More...
 
reference back ()
 Returns reference to last element of vector. More...
 
const_reference back () const
 Returns const reference to last element of vector. More...
 

Friends

std::ostream & operator<< (std::ostream &s, const ReservedDeque &v)
 Send ReservedDeque to an output stream. More...
 
size_type size () const
 Returns number of elements in the vector. More...
 
bool empty () const
 Returns true if vector has no elements. More...
 
static constexpr size_type capacity ()
 Returns current capacity (allocated memory) of the vector. More...
 
static constexpr size_type max_size ()
 Returns the maximum length of the vector. More...
 

Detailed Description

template<class T, int n>
class Dune::Functions::ReservedDeque< T, n >

A double-ended queue (deque) class with statically reserved memory.

ReservedDeque is something between std::array and std::deque. You have a double ended queue which can be extended and shrunk using methods like push_back and pop_back at the end, or via push_front and pop_front, but reserved memory is predefined.

This implies that the deque cannot grow bigger than the predefined maximum size.

Template Parameters
TThe data type ReservedDeque stores
nThe maximum number of objects the ReservedDeque can store

Member Typedef Documentation

◆ const_iterator

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

Const iterator used to iterate through a vector.

◆ const_reference

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

Const reference to T.

◆ difference_type

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

A signed integral type.

◆ iterator

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

Iterator used to iterate through a vector.

◆ pointer

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

Pointer to T.

◆ reference

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

Reference to T.

◆ size_type

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

An unsigned integral type.

◆ value_type

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

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

Typedefs

Constructor & Destructor Documentation

◆ ReservedDeque() [1/2]

template<class T , int n>
Dune::Functions::ReservedDeque< T, n >::ReservedDeque ( )
inline

Constructor.

Constructors

◆ ReservedDeque() [2/2]

template<class T , int n>
Dune::Functions::ReservedDeque< T, n >::ReservedDeque ( std::initializer_list< T > const &  l)
inline

Member Function Documentation

◆ back() [1/2]

template<class T , int n>
reference Dune::Functions::ReservedDeque< T, n >::back ( )
inline

Returns reference to last element of vector.

◆ back() [2/2]

template<class T , int n>
const_reference Dune::Functions::ReservedDeque< T, n >::back ( ) const
inline

Returns const reference to last element of vector.

◆ begin() [1/2]

template<class T , int n>
iterator Dune::Functions::ReservedDeque< T, n >::begin ( )
inline

Returns a iterator pointing to the beginning of the vector.

◆ begin() [2/2]

template<class T , int n>
const_iterator Dune::Functions::ReservedDeque< T, n >::begin ( ) const
inline

Returns a const_iterator pointing to the beginning of the vector.

◆ capacity()

template<class T , int n>
static constexpr size_type Dune::Functions::ReservedDeque< T, n >::capacity ( )
inlinestaticconstexpr

Returns current capacity (allocated memory) of the vector.

◆ clear()

template<class T , int n>
void Dune::Functions::ReservedDeque< T, n >::clear ( )
inline

Erases all elements.

Data access operations

◆ empty()

template<class T , int n>
bool Dune::Functions::ReservedDeque< T, n >::empty ( ) const
inline

Returns true if vector has no elements.

◆ end() [1/2]

template<class T , int n>
iterator Dune::Functions::ReservedDeque< T, n >::end ( )
inline

Returns an iterator pointing to the end of the vector.

◆ end() [2/2]

template<class T , int n>
const_iterator Dune::Functions::ReservedDeque< T, n >::end ( ) const
inline

Returns a const_iterator pointing to the end of the vector.

◆ front() [1/2]

template<class T , int n>
reference Dune::Functions::ReservedDeque< T, n >::front ( )
inline

Returns reference to first element of vector.

◆ front() [2/2]

template<class T , int n>
const_reference Dune::Functions::ReservedDeque< T, n >::front ( ) const
inline

Returns const reference to first element of vector.

◆ max_size()

template<class T , int n>
static constexpr size_type Dune::Functions::ReservedDeque< T, n >::max_size ( )
inlinestaticconstexpr

Returns the maximum length of the vector.

◆ operator[]() [1/2]

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

Returns reference to the i'th element.

◆ operator[]() [2/2]

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

Returns a const reference to the i'th element.

◆ pop_back()

template<class T , int n>
void Dune::Functions::ReservedDeque< T, n >::pop_back ( )
inline

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

◆ pop_front()

template<class T , int n>
void Dune::Functions::ReservedDeque< T, n >::pop_front ( )
inline

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

◆ push_back()

template<class T , int n>
void Dune::Functions::ReservedDeque< 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.

◆ push_front()

template<class T , int n>
void Dune::Functions::ReservedDeque< T, n >::push_front ( const T &  t)
inline

Prepends an element to the begin of a deque if size<capacity, O(1) time.

◆ resize()

template<class T , int n>
void Dune::Functions::ReservedDeque< T, n >::resize ( size_t  s)
inline

Specifies a new size for the vector.

◆ size()

template<class T , int n>
size_type Dune::Functions::ReservedDeque< T, n >::size ( ) const
inline

Returns number of elements in the vector.

Informative Methods

Friends And Related Function Documentation

◆ operator<<

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

Send ReservedDeque to an output stream.


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