Dune-Functions 2.11
Loading...
Searching...
No Matches
Dune::Functions::OverflowArray< BA, maxSize > Class Template Reference

A dynamically sized array-like class with overflow. More...

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

Inheritance diagram for Dune::Functions::OverflowArray< BA, maxSize >:
Inheritance graph

Public Types

using BaseArray = BA
using value_type = typename BaseArray::value_type
using reference = value_type&
using const_reference = const value_type&
using pointer = value_type*
using difference_type = std::ptrdiff_t
using size_type = std::size_t
using iterator = Dune::GenericIterator<OverflowArray, value_type>
using const_iterator = Dune::GenericIterator<const OverflowArray, const value_type>

Public Member Functions

 OverflowArray ()=default
 OverflowArray (const std::initializer_list< value_type > &l)
bool operator== (const OverflowArray &other) const
void clear ()
 Erases all elements.
void resize (size_type n)
 Specifies a new size for the OverflowArray.
void push_back (const value_type &t)
 Appends an element to the end of the OverflowArray,.
void pop_back ()
 Erases the last element of the OverflowArray, O(1) time.
void push_front (const value_type &t)
 Inserts an element to the begin of the OverflowArray,.
iterator begin ()
 Returns a iterator pointing to the beginning of the OverflowArray.
const_iterator begin () const
 Returns a const_iterator pointing to the beginning of the OverflowArray.
iterator end ()
 Returns an iterator pointing to the end of the OverflowArray.
const_iterator end () const
 Returns a const_iterator pointing to the end of the OverflowArray.
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 OverflowArray.
const_reference front () const
 Returns const reference to first element of OverflowArray.
reference back ()
 Returns reference to last element of OverflowArray.
const_reference back () const
 Returns const reference to last element of OverflowArray.
size_type size () const
 Returns number of elements in the OverflowArray.
bool empty () const
 Returns true if OverflowArray has no elements.

Static Public Member Functions

static constexpr size_type capacity ()
 Returns the capacity of the OverflowArray.
static constexpr size_type max_size ()
 Returns the maximum length of the OverflowArray.

Friends

std::size_t hash_value (const OverflowArray &v) noexcept
 Compute hash value.
std::ostream & operator<< (std::ostream &s, const OverflowArray &c)
 Write container to an output stream.

Detailed Description

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
class Dune::Functions::OverflowArray< BA, maxSize >

A dynamically sized array-like class with overflow.

Template Parameters
BAType of base array
maxSizeMaximal size of OverflowArray

This class publicly inherits from a statically sized array-like base class BA and extends it by an overflow such that a total capacity of maxSize is available. Within this bound the size is managed dynamically.

Potential usecase: If you want to construct a statically sized array but need dynamic resizing while building it, you can use an OverflowArray<std::array<T,finalSize>, ...> and cast the result to the base class type.

Similar to Dune::ReservedVector this uses a std::array internally with the following implications: Entries must be default-constructible. The whole capacity will always be filled with entries, even if size<capacity. Entries are only destructed when the OverflowArray is destructed - not when shrinking or clearing it.

Member Typedef Documentation

◆ BaseArray

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::BaseArray = BA

◆ const_iterator

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::const_iterator = Dune::GenericIterator<const OverflowArray, const value_type>

◆ const_reference

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::const_reference = const value_type&

◆ difference_type

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::difference_type = std::ptrdiff_t

◆ iterator

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::iterator = Dune::GenericIterator<OverflowArray, value_type>

◆ pointer

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::pointer = value_type*

◆ reference

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::reference = value_type&

◆ size_type

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::size_type = std::size_t

◆ value_type

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
using Dune::Functions::OverflowArray< BA, maxSize >::value_type = typename BaseArray::value_type

Constructor & Destructor Documentation

◆ OverflowArray() [1/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
Dune::Functions::OverflowArray< BA, maxSize >::OverflowArray ( )
default

◆ OverflowArray() [2/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
Dune::Functions::OverflowArray< BA, maxSize >::OverflowArray ( const std::initializer_list< value_type > & l)
inline

Member Function Documentation

◆ back() [1/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
reference Dune::Functions::OverflowArray< BA, maxSize >::back ( )
inline

Returns reference to last element of OverflowArray.

◆ back() [2/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
const_reference Dune::Functions::OverflowArray< BA, maxSize >::back ( ) const
inline

Returns const reference to last element of OverflowArray.

◆ begin() [1/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
iterator Dune::Functions::OverflowArray< BA, maxSize >::begin ( )
inline

Returns a iterator pointing to the beginning of the OverflowArray.

◆ begin() [2/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
const_iterator Dune::Functions::OverflowArray< BA, maxSize >::begin ( ) const
inline

Returns a const_iterator pointing to the beginning of the OverflowArray.

◆ capacity()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
constexpr size_type Dune::Functions::OverflowArray< BA, maxSize >::capacity ( )
inlinestaticconstexpr

Returns the capacity of the OverflowArray.

◆ clear()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
void Dune::Functions::OverflowArray< BA, maxSize >::clear ( )
inline

Erases all elements.

◆ empty()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
bool Dune::Functions::OverflowArray< BA, maxSize >::empty ( ) const
inline

Returns true if OverflowArray has no elements.

◆ end() [1/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
iterator Dune::Functions::OverflowArray< BA, maxSize >::end ( )
inline

Returns an iterator pointing to the end of the OverflowArray.

◆ end() [2/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
const_iterator Dune::Functions::OverflowArray< BA, maxSize >::end ( ) const
inline

Returns a const_iterator pointing to the end of the OverflowArray.

◆ front() [1/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
reference Dune::Functions::OverflowArray< BA, maxSize >::front ( )
inline

Returns reference to first element of OverflowArray.

◆ front() [2/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
const_reference Dune::Functions::OverflowArray< BA, maxSize >::front ( ) const
inline

Returns const reference to first element of OverflowArray.

◆ max_size()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
constexpr size_type Dune::Functions::OverflowArray< BA, maxSize >::max_size ( )
inlinestaticconstexpr

Returns the maximum length of the OverflowArray.

◆ operator==()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
bool Dune::Functions::OverflowArray< BA, maxSize >::operator== ( const OverflowArray< BA, maxSize > & other) const
inline

◆ operator[]() [1/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
reference Dune::Functions::OverflowArray< BA, maxSize >::operator[] ( size_type i)
inline

Returns reference to the i'th element.

◆ operator[]() [2/2]

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
const_reference Dune::Functions::OverflowArray< BA, maxSize >::operator[] ( size_type i) const
inline

Returns a const reference to the i'th element.

◆ pop_back()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
void Dune::Functions::OverflowArray< BA, maxSize >::pop_back ( )
inline

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

◆ push_back()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
void Dune::Functions::OverflowArray< BA, maxSize >::push_back ( const value_type & t)
inline

Appends an element to the end of the OverflowArray,.

The new size must not exceed max_size(). This is an O(1) operation.

◆ push_front()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
void Dune::Functions::OverflowArray< BA, maxSize >::push_front ( const value_type & t)
inline

Inserts an element to the begin of the OverflowArray,.

The new size must not exceed max_size(). This is an O(size()) operation.

◆ resize()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
void Dune::Functions::OverflowArray< BA, maxSize >::resize ( size_type n)
inline

Specifies a new size for the OverflowArray.

The new size must not exceed max_size(). This is an O(1) operation.

◆ size()

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
size_type Dune::Functions::OverflowArray< BA, maxSize >::size ( ) const
inline

Returns number of elements in the OverflowArray.

◆ hash_value

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
std::size_t hash_value ( const OverflowArray< BA, maxSize > & v)
friend

Compute hash value.

◆ operator<<

template<class BA, std::size_t maxSize = std::tuple_size_v<BA>>
std::ostream & operator<< ( std::ostream & s,
const OverflowArray< BA, maxSize > & c )
friend

Write container to an output stream.


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