3 #ifndef DUNE_COMMON_RESERVEDVECTOR_HH 4 #define DUNE_COMMON_RESERVEDVECTOR_HH 14 #include <initializer_list> 16 #ifdef CHECK_RESERVEDVECTOR 17 #define CHECKSIZE(X) assert(X) 19 #define CHECKSIZE(X) {} 38 template<
class T,
int n>
71 assert(l.size() <= n);
73 std::copy_n(l.begin(), sz, data);
122 const_iterator
end()
const {
172 size_type
size ()
const 201 for (
size_t i=0; i<v.
size(); i++)
215 #endif // DUNE_COMMON_RESERVEDVECTOR_HH iterator end()
Returns an iterator pointing to the end of the vector.
Definition: reservedvector.hh:117
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:94
ReservedVector()
Constructor.
Definition: reservedvector.hh:67
void pop_back()
Erases the last element of the vector, O(1) time.
Definition: reservedvector.hh:101
reference operator[](size_type i)
Returns reference to the i'th element.
Definition: reservedvector.hh:127
const_reference front() const
Returns const reference to first element of vector.
Definition: reservedvector.hh:148
void resize(size_t s)
Specifies a new size for the vector.
Definition: reservedvector.hh:87
size_t size_type
An unsigned integral type.
Definition: reservedvector.hh:54
const_reference back() const
Returns const reference to last element of vector.
Definition: reservedvector.hh:162
T * pointer
Pointer to T.
Definition: reservedvector.hh:48
size_type size() const
Returns number of elements in the vector.
Definition: reservedvector.hh:173
Implements a generic iterator class for writing stl conformant iterators.
T & reference
Reference to T.
Definition: reservedvector.hh:50
static DUNE_CONSTEXPR size_type max_size()
Returns the maximum length of the vector.
Definition: reservedvector.hh:191
reference back()
Returns reference to last element of vector.
Definition: reservedvector.hh:155
reference front()
Returns reference to first element of vector.
Definition: reservedvector.hh:141
const_iterator end() const
Returns a const_iterator pointing to the end of the vector.
Definition: reservedvector.hh:122
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the vector.
Definition: reservedvector.hh:112
ReservedVector(std::initializer_list< T > const &l)
Definition: reservedvector.hh:69
Generic class for stl-conforming iterators for container classes with operator[]. ...
Definition: genericiterator.hh:149
#define DUNE_CONSTEXPR
Set method or expression constexpr if supported by the compiler.
Definition: constexpr.hh:21
#define CHECKSIZE(X)
Definition: reservedvector.hh:19
Dune::GenericIterator< ReservedVector, value_type > iterator
Iterator used to iterate through a vector.
Definition: reservedvector.hh:58
T value_type
The type of object, T, stored in the vector.
Definition: reservedvector.hh:46
static DUNE_CONSTEXPR size_type capacity()
Returns current capacity (allocated memory) of the vector.
Definition: reservedvector.hh:185
Dune::GenericIterator< const ReservedVector, const value_type > const_iterator
Const iterator used to iterate through a vector.
Definition: reservedvector.hh:60
iterator begin()
Returns a iterator pointing to the beginning of the vector.
Definition: reservedvector.hh:107
const T & const_reference
Const reference to T.
Definition: reservedvector.hh:52
void clear()
Erases all elements.
Definition: reservedvector.hh:81
std::ptrdiff_t difference_type
A signed integral type.
Definition: reservedvector.hh:56
T t
Definition: alignment.hh:34
bool empty() const
Returns true if vector has no elements.
Definition: reservedvector.hh:179
friend std::ostream & operator<<(std::ostream &s, const ReservedVector &v)
Send ReservedVector to an output stream.
Definition: reservedvector.hh:199
A Vector class with statically reserved memory.
Definition: reservedvector.hh:39
Dune namespace.
Definition: alignment.hh:9