Clingo
|
A vector that misuses the begin, end and capacity pointers to store elements. More...
#include <small_vector.hh>
Public Member Functions | |
small_vector ()=default | |
Construct an empty vector. | |
small_vector (small_vector const &other) | |
Copy construct the vector. | |
small_vector (small_vector &&other) noexcept | |
Move construct the vector. | |
template<std::input_iterator It, std::sentinel_for< It > Is> | |
small_vector (It begin, Is end) | |
Initialize vector from an iterator range. | |
template<std::input_iterator It, std::sentinel_for< It > Is> | |
void | assign (It first, Is last) |
Assign the vector. | |
auto | operator= (small_vector const &other) -> small_vector & |
Copy assign the vector. | |
auto | operator= (small_vector &&other) noexcept -> small_vector & |
Move assign the vector. | |
void | resize (size_t n) |
Resize to the given size. | |
auto | size () const -> size_t |
Get the size of the vector. | |
auto | empty () const -> bool |
Check if the vector is empty. | |
auto | capacity () const -> size_t |
Get the capacity of the vector. | |
auto | begin () -> iterator |
Get an iterator to the beginning of the vector. | |
auto | begin () const -> const_iterator |
Get a const iterator to the beginning of the vector. | |
auto | cbegin () const -> const_iterator |
Get a const iterator to the beginning of the vector. | |
auto | end () -> iterator |
Get an iterator to the end of the vector. | |
auto | end () const -> const_iterator |
Get a const iterator to the end of the vector. | |
auto | cend () const -> const_iterator |
Get a const iterator to the end of the vector. | |
auto | data () -> iterator |
Get a pointer to the stored C array. | |
auto | data () const -> const_iterator |
Get a const pointer to the stored C array. | |
auto | cdata () const -> const_iterator |
Get a const pointer to the stored C array. | |
auto | operator[] (size_t i) -> reference |
Get the element at the given index. | |
auto | operator[] (size_t i) const -> const_reference |
Get the element at the given index. | |
void | reserve (size_t n) |
Reserve space for at least n elements. | |
auto | front () -> reference |
Get the first element in the vector. | |
auto | front () const -> const_reference |
Get the first element in the vector. | |
auto | back () -> reference |
Get the last element in the vector. | |
auto | back () const -> const_reference |
Get the last element in the vector. | |
auto | erase (iterator it) -> iterator |
Erase the given element. | |
auto | erase (iterator first, iterator last) -> iterator |
Erase the given range of elements. | |
template<class... U> | |
void | emplace (const_iterator loc, U &&...args) |
Emplace an element before the given iterator. | |
template<class... U> | |
void | emplace_back (U &&...args) |
Emplace an element after the last element. | |
void | push_back (value_type const &x) |
Append an element after the last element. | |
void | pop_back () |
Pop the last element. | |
void | clear () noexcept |
Clear the vector. | |
~small_vector () noexcept | |
Deconstruct the vector. | |
Friends | |
auto | operator<=> (small_vector const &lhs, small_vector const &rhs) |
auto | operator== (small_vector const &lhs, small_vector const &rhs) |
A vector that misuses the begin, end and capacity pointers to store elements.
This optimization makes it well-suited to store a large number of vectors with up to N elements witout allocating. Value N is best chosen to not extend the size of the vector.
|
inlinenoexcept |
Clear the vector.
Note that this frees allocated storage.