Dune Core Modules (2.9.0)

Dune::Functions::OverflowArray< BA, maxSize > Class Template Reference

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

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

Public Member Functions

void clear ()
 Erases all elements.
 
void resize (size_type n)
 Specifies a new size for the OverflowArray. More...
 
void push_back (const value_type &t)
 Appends an element to the end of the OverflowArray,. More...
 
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,. More...
 
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 Function Documentation

◆ 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.

References Dune::Functions::OverflowArray< BA, maxSize >::capacity(), and Dune::Functions::OverflowArray< BA, maxSize >::size().

◆ 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.

References Dune::Functions::OverflowArray< BA, maxSize >::capacity(), and Dune::Functions::OverflowArray< BA, maxSize >::size().

◆ 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.

References Dune::Functions::OverflowArray< BA, maxSize >::capacity().


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)