|
| constexpr | small_vector () noexcept |
| | Default ctor.
|
| |
| | ~small_vector () |
| | Dtor.
|
| |
| value_type & | operator[] (size_t index) noexcept |
| | Access an element.
|
| |
| value_type const & | operator[] (size_t index) const noexcept |
| | Access an element.
|
| |
| value_type & | front () noexcept |
| | Access the first element.
|
| |
| value_type const & | front () const noexcept |
| | Access the first element.
|
| |
| value_type & | back () noexcept |
| | Access the last element.
|
| |
| value_type const & | back () const noexcept |
| | Access the last element.
|
| |
| value_type * | data () noexcept |
| | Access the data array.
|
| |
| value_type const * | data () const noexcept |
| | Access the data array.
|
| |
| bool | empty () const noexcept |
| | Check if the vector is empty.
|
| |
| size_t | size () const noexcept |
| | Return the number of elements stored in the vector.
|
| |
| void | reserve (size_t new_cap) |
| | Reserve memory to accommodate at least the given number of elements.
|
| |
| size_t | capacity () const noexcept |
| | Return the number of elements for which memory is currently reesrved.
|
| |
| void | clear () noexcept |
| | Erase all elements from the vector.
|
| |
| void | clear_and_release () noexcept |
| | Erase all elements from the vector and release all heap memory.
|
| |
| void | push_back (value_type const &v) |
| | Append an element to the vector using the copy constructor.
|
| |
| template<class... Args> |
| void | emplace_back (Args &&... args) |
| | Append an element to the vector by construct in-place.
|
| |
| void | pop_back () noexcept |
| | Remove the last element.
|
| |
| void | resize (size_t count, value_type const &x=value_type()) |
| | Resize the number of elements in the vector.
|
| |
template<typename T, int8_t Prealloc = 1, typename Allocator = typename Config::Allocator<T>::type>
class zth::small_vector< T, Prealloc, Allocator >
A simple std::vector, which can contain Prealloc without heap allocation.
When the internal buffer is exhausted, the vector grows automatically into an std::vector, using heap memory after all.
In all cases, the elements are stored in contiguous memory, like guaranteed by std::vector. Upon a push_back(), underlying memory may be reallocated to accommodate the new element, which renders previous pointers invalid.
- Template Parameters
-
| T | the type of elements to contain |
| Prealloc | the minimum number of elements to contain without using heap |
| Allocator | the allocator to use for std::vector |
Definition at line 1213 of file util.h.