Go to the documentation of this file.
3 #ifndef DUNE_COMMON_RESERVEDVECTOR_HH
4 #define DUNE_COMMON_RESERVEDVECTOR_HH
14 #include <initializer_list>
18 #ifdef CHECK_RESERVEDVECTOR
19 #define CHECKSIZE(X) assert(X)
21 #define CHECKSIZE(X) {}
40 template<
class T,
int n>
73 assert(l.size() <= n);
75 std::copy_n(l.begin(), sz, data);
82 bool eq = (sz == other.sz);
84 eq =
eq && (data[i] == other.data[i]);
211 for (
size_t i=0; i<v.
size(); i++)
232 #endif // DUNE_COMMON_RESERVEDVECTOR_HH
friend std::size_t hash_value(const ReservedVector &v) noexcept
Definition: reservedvector.hh:216
const_reference back() const
Returns const reference to last element of vector.
Definition: reservedvector.hh:172
A Vector class with statically reserved memory.
Definition: reservedvector.hh:41
Dune::GenericIterator< ReservedVector, value_type > iterator
Iterator used to iterate through a vector.
Definition: reservedvector.hh:60
friend std::ostream & operator<<(std::ostream &s, const ReservedVector &v)
Send ReservedVector to an output stream.
Definition: reservedvector.hh:209
ReservedVector()
Constructor.
Definition: reservedvector.hh:69
#define DUNE_DEFINE_HASH(template_args, type)
Defines the required struct specialization to make type hashable via Dune::hash.
Definition: hash.hh:98
const typedef T & const_reference
Const reference to T.
Definition: reservedvector.hh:54
Support for calculating hash values of objects.
const_reference front() const
Returns const reference to first element of vector.
Definition: reservedvector.hh:158
T * pointer
Pointer to T.
Definition: reservedvector.hh:50
Dune namespace.
Definition: alignedallocator.hh:9
reference front()
Returns reference to first element of vector.
Definition: reservedvector.hh:151
bool empty() const
Returns true if vector has no elements.
Definition: reservedvector.hh:189
Implements a generic iterator class for writing stl conformant iterators.
T & reference
Reference to T.
Definition: reservedvector.hh:52
reference back()
Returns reference to last element of vector.
Definition: reservedvector.hh:165
void clear()
Erases all elements.
Definition: reservedvector.hh:91
void push_back(const T &t)
Appends an element to the end of a vector, up to the maximum size n, O(1) time.
Definition: reservedvector.hh:104
iterator end()
Returns an iterator pointing to the end of the vector.
Definition: reservedvector.hh:127
size_type size() const
Returns number of elements in the vector.
Definition: reservedvector.hh:183
reference operator[](size_type i)
Returns reference to the i'th element.
Definition: reservedvector.hh:137
void resize(size_t s)
Specifies a new size for the vector.
Definition: reservedvector.hh:97
static constexpr size_type max_size()
Returns the maximum length of the vector.
Definition: reservedvector.hh:201
const_iterator end() const
Returns a const_iterator pointing to the end of the vector.
Definition: reservedvector.hh:132
#define DUNE_HASH_TYPE(...)
Wrapper macro for the type to be hashed in DUNE_DEFINE_HASH.
Definition: hash.hh:115
bool eq(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test for equality using epsilon
Definition: float_cmp.cc:133
Dune::GenericIterator< const ReservedVector, const value_type > const_iterator
Const iterator used to iterate through a vector.
Definition: reservedvector.hh:62
#define CHECKSIZE(X)
Definition: reservedvector.hh:21
iterator begin()
Returns a iterator pointing to the beginning of the vector.
Definition: reservedvector.hh:117
ReservedVector(std::initializer_list< T > const &l)
Definition: reservedvector.hh:71
std::size_t hash_range(It first, It last)
Hashes all elements in the range [first,last) and returns the combined hash.
Definition: hash.hh:320
Generic class for stl-conforming iterators for container classes with operator[].
Definition: genericiterator.hh:149
static constexpr size_type capacity()
Returns current capacity (allocated memory) of the vector.
Definition: reservedvector.hh:195
T value_type
The type of object, T, stored in the vector.
Definition: reservedvector.hh:48
std::ptrdiff_t difference_type
A signed integral type.
Definition: reservedvector.hh:58
void pop_back()
Erases the last element of the vector, O(1) time.
Definition: reservedvector.hh:111
size_t size_type
An unsigned integral type.
Definition: reservedvector.hh:56
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the vector.
Definition: reservedvector.hh:122
Get the 'const' version of a reference to a mutable object.
Definition: genericiterator.hh:84
bool operator==(const ReservedVector &other) const
Definition: reservedvector.hh:80
#define DUNE_HASH_TEMPLATE_ARGS(...)
Wrapper macro for the template arguments in DUNE_DEFINE_HASH.
Definition: hash.hh:107