dune-functions 2.9.0
|
A dynamically sized array-like class with overflow. More...
#include <dune/functions/common/overflowarray.hh>
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. More... | |
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. More... | |
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. More... | |
const_iterator | begin () const |
Returns a const_iterator pointing to the beginning of the OverflowArray. More... | |
iterator | end () |
Returns an iterator pointing to the end of the OverflowArray. More... | |
const_iterator | end () const |
Returns a const_iterator pointing to the end of the OverflowArray. 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 OverflowArray. More... | |
const_reference | front () const |
Returns const reference to first element of OverflowArray. More... | |
reference | back () |
Returns reference to last element of OverflowArray. More... | |
const_reference | back () const |
Returns const reference to last element of OverflowArray. More... | |
size_type | size () const |
Returns number of elements in the OverflowArray. More... | |
bool | empty () const |
Returns true if OverflowArray has no elements. More... | |
Static Public Member Functions | |
static constexpr size_type | capacity () |
Returns the capacity of the OverflowArray. More... | |
static constexpr size_type | max_size () |
Returns the maximum length of the OverflowArray. More... | |
Friends | |
std::size_t | hash_value (const OverflowArray &v) noexcept |
Compute hash value. More... | |
std::ostream & | operator<< (std::ostream &s, const OverflowArray &c) |
Write container to an output stream. More... | |
A dynamically sized array-like class with overflow.
BA | Type of base array |
maxSize | Maximal 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.
using Dune::Functions::OverflowArray< BA, maxSize >::BaseArray = BA |
using Dune::Functions::OverflowArray< BA, maxSize >::const_iterator = Dune::GenericIterator<const OverflowArray, const value_type> |
using Dune::Functions::OverflowArray< BA, maxSize >::const_reference = const value_type& |
using Dune::Functions::OverflowArray< BA, maxSize >::difference_type = std::ptrdiff_t |
using Dune::Functions::OverflowArray< BA, maxSize >::iterator = Dune::GenericIterator<OverflowArray, value_type> |
using Dune::Functions::OverflowArray< BA, maxSize >::pointer = value_type* |
using Dune::Functions::OverflowArray< BA, maxSize >::reference = value_type& |
using Dune::Functions::OverflowArray< BA, maxSize >::size_type = std::size_t |
using Dune::Functions::OverflowArray< BA, maxSize >::value_type = typename BaseArray::value_type |
|
default |
|
inline |
|
inline |
Returns reference to last element of OverflowArray.
|
inline |
Returns const reference to last element of OverflowArray.
|
inline |
Returns a iterator pointing to the beginning of the OverflowArray.
|
inline |
Returns a const_iterator pointing to the beginning of the OverflowArray.
|
inlinestaticconstexpr |
Returns the capacity of the OverflowArray.
|
inline |
Erases all elements.
|
inline |
Returns true if OverflowArray has no elements.
|
inline |
Returns an iterator pointing to the end of the OverflowArray.
|
inline |
Returns a const_iterator pointing to the end of the OverflowArray.
|
inline |
Returns reference to first element of OverflowArray.
|
inline |
Returns const reference to first element of OverflowArray.
|
inlinestaticconstexpr |
Returns the maximum length of the OverflowArray.
|
inline |
|
inline |
Returns reference to the i'th element.
|
inline |
Returns a const reference to the i'th element.
|
inline |
Erases the last element of the OverflowArray, O(1) time.
|
inline |
Appends an element to the end of the OverflowArray,.
The new size must not exceed max_size(). This is an O(1) operation.
|
inline |
Inserts an element to the begin of the OverflowArray,.
The new size must not exceed max_size(). This is an O(size()) operation.
|
inline |
Specifies a new size for the OverflowArray.
The new size must not exceed max_size(). This is an O(1) operation.
|
inline |
Returns number of elements in the OverflowArray.
|
friend |
Compute hash value.
|
friend |
Write container to an output stream.