dune-common  2.11
Friends | List of all members
Dune::ReservedVector< T, n > Class Template Reference

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

#include <dune/common/reservedvector.hh>

Public Types

typedef storage_type::value_type value_type
 The type of object, T, stored in the vector. More...
 
typedef storage_type::pointer pointer
 Pointer to T. More...
 
typedef storage_type::const_pointer const_pointer
 Const pointer to T. More...
 
typedef storage_type::reference reference
 Reference to T. More...
 
typedef storage_type::const_reference const_reference
 Const reference to T. More...
 
typedef storage_type::size_type size_type
 An unsigned integral type. More...
 
typedef storage_type::difference_type difference_type
 A signed integral type. More...
 
typedef storage_type::iterator iterator
 Iterator used to iterate through a vector. More...
 
typedef storage_type::const_iterator const_iterator
 Const iterator used to iterate through a vector. More...
 
typedef std::reverse_iterator< iteratorreverse_iterator
 Reverse iterator. More...
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 Const reverse iterator. More...
 

Public Member Functions

constexpr ReservedVector () noexcept(std::is_nothrow_default_constructible_v< value_type >)
 Constructs an empty vector. More...
 
constexpr ReservedVector (size_type count) noexcept(std::is_nothrow_default_constructible_v< value_type >)
 Constructs the vector with count elements that will be default-initialized. More...
 
constexpr ReservedVector (size_type count, const value_type &value) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector(count)))
 Constructs the vector with count copies of elements with value value. More...
 
template<class InputIt , std::enable_if_t< std::is_convertible_v< typename std::iterator_traits< InputIt >::value_type, value_type >, int > = 0>
constexpr ReservedVector (InputIt first, InputIt last) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector()))
 Constructs the vector from an iterator range [first,last) More...
 
constexpr ReservedVector (std::initializer_list< value_type > const &l) noexcept(std::is_nothrow_copy_assignable_v< value_type > &&noexcept(ReservedVector(l.begin(), l.end())))
 Constructs the vector from an initializer list. More...
 
constexpr bool operator== (const ReservedVector &that) const noexcept
 Compares the values in the vector this with that for equality. More...
 
constexpr auto operator (const ReservedVector &that) const noexcept
 Lexicographically compares the values in the vector this with that More...
 
constexpr void clear () noexcept
 Erases all elements. More...
 
constexpr void resize (size_type s) noexcept
 Specifies a new size for the vector. More...
 
constexpr void push_back (const value_type &t) noexcept(std::is_nothrow_copy_assignable_v< value_type >)
 Appends an element to the end of a vector, up to the maximum size n, O(1) time. More...
 
constexpr void push_back (value_type &&t) noexcept(std::is_nothrow_move_assignable_v< value_type >)
 Appends an element to the end of a vector by moving the value, up to the maximum size n, O(1) time. More...
 
template<class... Args>
reference emplace_back (Args &&... args) noexcept(std::is_nothrow_constructible_v< value_type, decltype(args)... >)
 Appends an element to the end of a vector by constructing it in place. More...
 
constexpr void pop_back () noexcept
 Erases the last element of the vector, O(1) time. More...
 
constexpr iterator begin () noexcept
 Returns a iterator pointing to the beginning of the vector. More...
 
constexpr const_iterator begin () const noexcept
 Returns a const_iterator pointing to the beginning of the vector. More...
 
constexpr const_iterator cbegin () const noexcept
 Returns a const_iterator pointing to the beginning of the vector. More...
 
constexpr reverse_iterator rbegin () noexcept
 Returns a const reverse-iterator pointing to the end of the vector. More...
 
constexpr const_reverse_iterator rbegin () const noexcept
 Returns a const reverse-iterator pointing to the end of the vector. More...
 
constexpr const_reverse_iterator crbegin () const noexcept
 Returns a const reverse-iterator pointing to the end of the vector. More...
 
constexpr iterator end () noexcept
 Returns an iterator pointing to the end of the vector. More...
 
constexpr const_iterator end () const noexcept
 Returns a const_iterator pointing to the end of the vector. More...
 
constexpr const_iterator cend () const noexcept
 Returns a const_iterator pointing to the end of the vector. More...
 
constexpr reverse_iterator rend () noexcept
 Returns a const reverse-iterator pointing to the begin of the vector. More...
 
constexpr const_reverse_iterator rend () const noexcept
 Returns a const reverse-iterator pointing to the begin of the vector. More...
 
constexpr const_reverse_iterator crend () const noexcept
 Returns a const reverse-iterator pointing to the begin of the vector. More...
 
constexpr reference at (size_type i)
 Returns reference to the i'th element. More...
 
constexpr const_reference at (size_type i) const
 Returns a const reference to the i'th element. More...
 
constexpr reference operator[] (size_type i) noexcept
 Returns reference to the i'th element. More...
 
constexpr const_reference operator[] (size_type i) const noexcept
 Returns a const reference to the i'th element. More...
 
constexpr reference front () noexcept
 Returns reference to first element of vector. More...
 
constexpr const_reference front () const noexcept
 Returns const reference to first element of vector. More...
 
constexpr reference back () noexcept
 Returns reference to last element of vector. More...
 
constexpr const_reference back () const noexcept
 Returns const reference to last element of vector. More...
 
constexpr pointer data () noexcept
 Returns pointer to the underlying memory. More...
 
constexpr const_pointer data () const noexcept
 Returns const pointer to the underlying memory. More...
 
constexpr void fill (const value_type &value) noexcept(std::is_nothrow_copy_assignable_v< value_type >)
 Fill the container with the value. More...
 
void swap (ReservedVector &other) noexcept(std::is_nothrow_swappable_v< value_type >)
 Swap the content with another vector. More...
 

Friends

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

Detailed Description

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

A Vector class with statically reserved memory.

ReservedVector is something between std::array and std::vector. It is a dynamically sized vector which can be extended and shrunk using methods like push_back and pop_back, but reserved memory is statically predefined.

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

Template Parameters
TThe value type ReservedVector stores.
nThe maximum number of objects the ReservedVector can store.

Member Typedef Documentation

◆ const_iterator

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

Const iterator used to iterate through a vector.

◆ const_pointer

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

Const pointer to T.

◆ const_reference

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

Const reference to T.

◆ const_reverse_iterator

template<class T , int n>
typedef std::reverse_iterator<const_iterator> Dune::ReservedVector< T, n >::const_reverse_iterator

Const reverse iterator.

◆ difference_type

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

A signed integral type.

◆ iterator

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

Iterator used to iterate through a vector.

◆ pointer

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

Pointer to T.

◆ reference

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

Reference to T.

◆ reverse_iterator

template<class T , int n>
typedef std::reverse_iterator<iterator> Dune::ReservedVector< T, n >::reverse_iterator

Reverse iterator.

◆ size_type

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

An unsigned integral type.

◆ value_type

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

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

Typedefs

Constructor & Destructor Documentation

◆ ReservedVector() [1/5]

template<class T , int n>
constexpr Dune::ReservedVector< T, n >::ReservedVector ( )
inlinenoexcept

Constructs an empty vector.

Constructors

◆ ReservedVector() [2/5]

template<class T , int n>
constexpr Dune::ReservedVector< T, n >::ReservedVector ( size_type  count)
inlineexplicitnoexcept

Constructs the vector with count elements that will be default-initialized.

◆ ReservedVector() [3/5]

template<class T , int n>
constexpr Dune::ReservedVector< T, n >::ReservedVector ( size_type  count,
const value_type value 
)
inlinenoexcept

Constructs the vector with count copies of elements with value value.

◆ ReservedVector() [4/5]

template<class T , int n>
template<class InputIt , std::enable_if_t< std::is_convertible_v< typename std::iterator_traits< InputIt >::value_type, value_type >, int > = 0>
constexpr Dune::ReservedVector< T, n >::ReservedVector ( InputIt  first,
InputIt  last 
)
inlinenoexcept

Constructs the vector from an iterator range [first,last)

◆ ReservedVector() [5/5]

template<class T , int n>
constexpr Dune::ReservedVector< T, n >::ReservedVector ( std::initializer_list< value_type > const &  l)
inlinenoexcept

Constructs the vector from an initializer list.

Member Function Documentation

◆ at() [1/2]

template<class T , int n>
constexpr reference Dune::ReservedVector< T, n >::at ( size_type  i)
inline

Returns reference to the i'th element.

Element access

◆ at() [2/2]

template<class T , int n>
constexpr const_reference Dune::ReservedVector< T, n >::at ( size_type  i) const
inline

Returns a const reference to the i'th element.

◆ back() [1/2]

template<class T , int n>
constexpr reference Dune::ReservedVector< T, n >::back ( )
inlinenoexcept

Returns reference to last element of vector.

◆ back() [2/2]

template<class T , int n>
constexpr const_reference Dune::ReservedVector< T, n >::back ( ) const
inlinenoexcept

Returns const reference to last element of vector.

◆ begin() [1/2]

template<class T , int n>
constexpr iterator Dune::ReservedVector< T, n >::begin ( )
inlinenoexcept

Returns a iterator pointing to the beginning of the vector.

Iterators

◆ begin() [2/2]

template<class T , int n>
constexpr const_iterator Dune::ReservedVector< T, n >::begin ( ) const
inlinenoexcept

Returns a const_iterator pointing to the beginning of the vector.

◆ capacity()

template<class T , int n>
static constexpr size_type Dune::ReservedVector< T, n >::capacity ( )
inlinestaticnoexcept

Returns current capacity (allocated memory) of the vector.

◆ cbegin()

template<class T , int n>
constexpr const_iterator Dune::ReservedVector< T, n >::cbegin ( ) const
inlinenoexcept

Returns a const_iterator pointing to the beginning of the vector.

◆ cend()

template<class T , int n>
constexpr const_iterator Dune::ReservedVector< T, n >::cend ( ) const
inlinenoexcept

Returns a const_iterator pointing to the end of the vector.

◆ clear()

template<class T , int n>
constexpr void Dune::ReservedVector< T, n >::clear ( )
inlinenoexcept

Erases all elements.

Modifiers

◆ crbegin()

template<class T , int n>
constexpr const_reverse_iterator Dune::ReservedVector< T, n >::crbegin ( ) const
inlinenoexcept

Returns a const reverse-iterator pointing to the end of the vector.

◆ crend()

template<class T , int n>
constexpr const_reverse_iterator Dune::ReservedVector< T, n >::crend ( ) const
inlinenoexcept

Returns a const reverse-iterator pointing to the begin of the vector.

◆ data() [1/2]

template<class T , int n>
constexpr pointer Dune::ReservedVector< T, n >::data ( )
inlinenoexcept

Returns pointer to the underlying memory.

◆ data() [2/2]

template<class T , int n>
constexpr const_pointer Dune::ReservedVector< T, n >::data ( ) const
inlinenoexcept

Returns const pointer to the underlying memory.

◆ emplace_back()

template<class T , int n>
template<class... Args>
reference Dune::ReservedVector< T, n >::emplace_back ( Args &&...  args)
inlinenoexcept

Appends an element to the end of a vector by constructing it in place.

◆ empty()

template<class T , int n>
constexpr bool Dune::ReservedVector< T, n >::empty ( ) const
inlinenoexcept

Returns true if vector has no elements.

◆ end() [1/2]

template<class T , int n>
constexpr iterator Dune::ReservedVector< T, n >::end ( )
inlinenoexcept

Returns an iterator pointing to the end of the vector.

◆ end() [2/2]

template<class T , int n>
constexpr const_iterator Dune::ReservedVector< T, n >::end ( ) const
inlinenoexcept

Returns a const_iterator pointing to the end of the vector.

◆ fill()

template<class T , int n>
constexpr void Dune::ReservedVector< T, n >::fill ( const value_type value)
inlinenoexcept

Fill the container with the value.

Operations

◆ front() [1/2]

template<class T , int n>
constexpr reference Dune::ReservedVector< T, n >::front ( )
inlinenoexcept

Returns reference to first element of vector.

◆ front() [2/2]

template<class T , int n>
constexpr const_reference Dune::ReservedVector< T, n >::front ( ) const
inlinenoexcept

Returns const reference to first element of vector.

◆ max_size()

template<class T , int n>
static constexpr size_type Dune::ReservedVector< T, n >::max_size ( )
inlinestaticnoexcept

Returns the maximum length of the vector.

◆ operator()

template<class T , int n>
constexpr auto Dune::ReservedVector< T, n >::operator ( const ReservedVector< T, n > &  that) const
inlinenoexcept

Lexicographically compares the values in the vector this with that

◆ operator==()

template<class T , int n>
constexpr bool Dune::ReservedVector< T, n >::operator== ( const ReservedVector< T, n > &  that) const
inlinenoexcept

Compares the values in the vector this with that for equality.

Comparison

◆ operator[]() [1/2]

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

Returns reference to the i'th element.

◆ operator[]() [2/2]

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

Returns a const reference to the i'th element.

◆ pop_back()

template<class T , int n>
constexpr void Dune::ReservedVector< T, n >::pop_back ( )
inlinenoexcept

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

◆ push_back() [1/2]

template<class T , int n>
constexpr void Dune::ReservedVector< T, n >::push_back ( const value_type t)
inlinenoexcept

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

◆ push_back() [2/2]

template<class T , int n>
constexpr void Dune::ReservedVector< T, n >::push_back ( value_type &&  t)
inlinenoexcept

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

◆ rbegin() [1/2]

template<class T , int n>
constexpr reverse_iterator Dune::ReservedVector< T, n >::rbegin ( )
inlinenoexcept

Returns a const reverse-iterator pointing to the end of the vector.

◆ rbegin() [2/2]

template<class T , int n>
constexpr const_reverse_iterator Dune::ReservedVector< T, n >::rbegin ( ) const
inlinenoexcept

Returns a const reverse-iterator pointing to the end of the vector.

◆ rend() [1/2]

template<class T , int n>
constexpr reverse_iterator Dune::ReservedVector< T, n >::rend ( )
inlinenoexcept

Returns a const reverse-iterator pointing to the begin of the vector.

◆ rend() [2/2]

template<class T , int n>
constexpr const_reverse_iterator Dune::ReservedVector< T, n >::rend ( ) const
inlinenoexcept

Returns a const reverse-iterator pointing to the begin of the vector.

◆ resize()

template<class T , int n>
constexpr void Dune::ReservedVector< T, n >::resize ( size_type  s)
inlinenoexcept

Specifies a new size for the vector.

◆ size()

template<class T , int n>
constexpr size_type Dune::ReservedVector< T, n >::size ( ) const
inlinenoexcept

Returns number of elements in the vector.

Capacity

◆ swap()

template<class T , int n>
void Dune::ReservedVector< T, n >::swap ( ReservedVector< T, n > &  other)
inlinenoexcept

Swap the content with another vector.

Friends And Related Function Documentation

◆ hash_value

template<class T , int n>
std::size_t hash_value ( const ReservedVector< T, n > &  v)
friend

◆ operator<<

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: