Gromacs
2024.4
|
#include <gromacs/utility/include/gromacs/utility/fixedcapacityvector.h>
Vector that behaves likes std::vector but has fixed capacity.
T | Value type of elements. |
capacity_ | The maximum number of elements that can be stored. |
This class provides a variable size container, but with constant memory usage and can be allocated on the stack and avoid the overhead of dynamic allocation. This is especially useful for small vectors which are set up frequently.
The class supports all methods from std::array
, but behaves more like std::vector
since it has variable size. In addition to the methods from std::array, from std::vector
the methods push_back()
, pop_back()
, emplace_back() and clear()
are supported. In particular, methods that requires reordering, such as insert()
and emplace()
are not supported to keep the code simple.
The size is 0 at construction and elements can only be added with push_back()
and emplace_back()
.
Public Types | |
using | value_type = T |
Type of values stored in the vector. | |
using | size_type = size_t |
Type for representing size of the vector. | |
using | difference_type = ptrdiff_t |
Type for representing difference between two indices. | |
using | const_reference = const T & |
Const reference to an element. | |
using | const_pointer = const T * |
Const pointer to an element. | |
using | const_iterator = const T * |
Const iterator type to an element. | |
using | reference = T & |
Reference to an element. | |
using | pointer = T * |
Pointer to an element. | |
using | iterator = T * |
Iterator type to an element. | |
using | reverse_iterator = std::reverse_iterator< iterator > |
Standard reverse iterator. | |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
Standard reverse iterator. | |
Public Member Functions | |
const_iterator | begin () const noexcept |
Returns a const iterator to the beginning. | |
iterator | begin () noexcept |
Returns an iterator to the beginning. | |
const_iterator | end () const noexcept |
Returns a const iterator to the end. | |
iterator | end () noexcept |
Returns an iterator to the end. | |
const_reverse_iterator | rbegin () const noexcept |
Returns a const iterator to the reverse beginning. | |
reverse_iterator | rbegin () noexcept |
Returns an iterator to the reverse beginning. | |
const_reverse_iterator | rend () const noexcept |
Returns a const iterator to the reverse end. | |
reverse_iterator | rend () noexcept |
Returns an iterator to the reverse end. | |
size_type | size () const noexcept |
Returns the size. More... | |
Index | ssize () const noexcept |
Returns the signed size. | |
bool | empty () const noexcept |
Returns whether the vector is empty. | |
const_reference | operator[] (size_type n) const noexcept |
Const access an element. | |
reference | operator[] (size_type n) noexcept |
Access an element. | |
const_reference | at (size_type n) const |
Const access an element, throws an out_of_range exception when out of range. | |
reference | at (size_type n) |
Access an element, throws an out_of_range exception when out of range. | |
reference | front () const noexcept |
Returns the first element. | |
reference | back () const noexcept |
Returns the last element. | |
const T * | data () const noexcept |
Returns a raw pointer to the contents of the array. | |
T * | data () noexcept |
Returns a raw pointer to the contents of the array. | |
void | push_back (const T &value) noexcept |
Adds element at the end. | |
void | pop_back () noexcept |
Deletes last element. | |
template<class... Args> | |
reference | emplace_back (Args &&...args) |
Constructs an element at the end. | |
void | clear () noexcept |
Clears content. | |
Static Public Member Functions | |
static constexpr size_type | max_size () noexcept |
Returns the vector capacity (max. number of elements that can be stored) | |
static constexpr size_type | capacity () noexcept |
Returns the vector capacity (max. number of elements that can be stored) | |
|
inlinenoexcept |
Returns the size.