3#ifndef DUNE_FUNCTIONS_COMMON_OVERFLOWARRAY_HH
4#define DUNE_FUNCTIONS_COMMON_OVERFLOWARRAY_HH
10#include <initializer_list>
12#include <dune/common/genericiterator.hh>
42template<
class BA, std::
size_t maxSize = std::tuple_size_v<BA>>
46 static constexpr std::size_t baseSize = std::tuple_size_v<BA>;
57 using iterator = Dune::GenericIterator<OverflowArray, value_type>;
58 using const_iterator = Dune::GenericIterator<const OverflowArray, const value_type>;
61 using OverflowBuffer = std::array<
value_type, maxSize-baseSize>;
70 std::copy_n(l.begin(), size_,
begin());
77 if ((*
this)[i] != other[i])
106 (*this)[size_++] = t;
125 (*
this)[i+1] = (*this)[i];
156 return BaseArray::operator[](i);
157 return overflow_[i-baseSize];
167 return BaseArray::operator[](i);
168 return overflow_[i-baseSize];
186 return (*
this)[
size()-1];
192 return (*
this)[
size()-1];
217 return hash_range(v.begin(), v.end());
222 for (
const auto& ci : c)
228 OverflowBuffer overflow_;
Definition: polynomial.hh:11
A dynamically sized array-like class with overflow.
Definition: overflowarray.hh:45
const value_type & const_reference
Definition: overflowarray.hh:53
value_type & reference
Definition: overflowarray.hh:52
const_iterator end() const
Returns a const_iterator pointing to the end of the OverflowArray.
Definition: overflowarray.hh:145
bool operator==(const OverflowArray &other) const
Definition: overflowarray.hh:73
friend std::size_t hash_value(const OverflowArray &v) noexcept
Compute hash value.
Definition: overflowarray.hh:216
void push_back(const value_type &t)
Appends an element to the end of the OverflowArray,.
Definition: overflowarray.hh:104
friend std::ostream & operator<<(std::ostream &s, const OverflowArray &c)
Write container to an output stream.
Definition: overflowarray.hh:221
iterator begin()
Returns a iterator pointing to the beginning of the OverflowArray.
Definition: overflowarray.hh:130
bool empty() const
Returns true if OverflowArray has no elements.
Definition: overflowarray.hh:201
size_type size() const
Returns number of elements in the OverflowArray.
Definition: overflowarray.hh:196
typename BaseArray::value_type value_type
Definition: overflowarray.hh:51
void pop_back()
Erases the last element of the OverflowArray, O(1) time.
Definition: overflowarray.hh:110
Dune::GenericIterator< OverflowArray, value_type > iterator
Definition: overflowarray.hh:57
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the OverflowArray.
Definition: overflowarray.hh:135
std::ptrdiff_t difference_type
Definition: overflowarray.hh:55
BA BaseArray
Definition: overflowarray.hh:49
static constexpr size_type capacity()
Returns the capacity of the OverflowArray.
Definition: overflowarray.hh:206
static constexpr size_type max_size()
Returns the maximum length of the OverflowArray.
Definition: overflowarray.hh:211
const_reference front() const
Returns const reference to first element of OverflowArray.
Definition: overflowarray.hh:178
void clear()
Erases all elements.
Definition: overflowarray.hh:83
iterator end()
Returns an iterator pointing to the end of the OverflowArray.
Definition: overflowarray.hh:140
std::size_t size_type
Definition: overflowarray.hh:56
void resize(size_type n)
Specifies a new size for the OverflowArray.
Definition: overflowarray.hh:93
value_type * pointer
Definition: overflowarray.hh:54
Dune::GenericIterator< const OverflowArray, const value_type > const_iterator
Definition: overflowarray.hh:58
const_reference back() const
Returns const reference to last element of OverflowArray.
Definition: overflowarray.hh:190
OverflowArray(const std::initializer_list< value_type > &l)
Definition: overflowarray.hh:67
reference back()
Returns reference to last element of OverflowArray.
Definition: overflowarray.hh:184
void push_front(const value_type &t)
Inserts an element to the begin of the OverflowArray,.
Definition: overflowarray.hh:122
reference front()
Returns reference to first element of OverflowArray.
Definition: overflowarray.hh:172
reference operator[](size_type i)
Returns reference to the i'th element.
Definition: overflowarray.hh:150