|
dispenso 1.5.1
A library for task parallelism
|
#include <small_vector.h>
Public Member Functions | |
| SmallVector () noexcept | |
| SmallVector (size_type count) | |
| SmallVector (size_type count, const T &value) | |
| SmallVector (std::initializer_list< T > init) | |
| SmallVector (const SmallVector &other) | |
| SmallVector (SmallVector &&other) noexcept | |
| reference | front () |
| const_reference | front () const |
| reference | back () |
| const_reference | back () const |
| pointer | data () noexcept |
| const_pointer | data () const noexcept |
| iterator | begin () noexcept |
| const_iterator | begin () const noexcept |
| const_iterator | cbegin () const noexcept |
| iterator | end () noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cend () const noexcept |
| bool | empty () const noexcept |
| size_type | size () const noexcept |
| size_type | capacity () const noexcept |
| void | reserve (size_type newCap) |
| void | clear () noexcept |
| void | push_back (const T &value) |
| void | push_back (T &&value) |
| template<typename... Args> | |
| reference | emplace_back (Args &&... args) |
| void | pop_back () |
| void | resize (size_type count) |
| void | resize (size_type count, const T &value) |
| iterator | erase (const_iterator pos) |
A vector-like container that stores up to N elements inline (on the stack), avoiding heap allocation for small sizes. Falls back to heap allocation when the size exceeds N.
| T | The element type. |
| N | The number of elements to store inline (default 4). Must be in range [1, 65535]. |
Memory layout: Uses a union to share space between inline storage and heap pointer/capacity. The high bit of the size field tracks whether heap storage is active, so no additional bool or flag field is needed.
Once on heap, the vector stays on heap until clear() is called. This ensures reserve() capacity is preserved across push_back/pop_back sequences.
Definition at line 48 of file small_vector.h.
|
inlinenoexcept |
Construct an empty SmallVector.
Definition at line 66 of file small_vector.h.
|
inlineexplicit |
Construct a SmallVector with count default-constructed elements.
| count | The number of elements. |
Definition at line 73 of file small_vector.h.
|
inline |
Construct a SmallVector with count copies of value.
| count | The number of elements. |
| value | The value to copy into each element. |
Definition at line 83 of file small_vector.h.
|
inline |
Construct a SmallVector from an initializer list.
| init | The initializer list of elements. |
Definition at line 92 of file small_vector.h.
|
inline |
Copy constructor.
Definition at line 100 of file small_vector.h.
|
inlinenoexcept |
Move constructor. Moves elements and leaves other empty.
Definition at line 108 of file small_vector.h.
|
inline |
Definition at line 123 of file small_vector.h.
|
inline |
Access the last element.
Definition at line 181 of file small_vector.h.
|
inline |
Access the last element.
Definition at line 185 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 205 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 201 of file small_vector.h.
|
inlinenoexcept |
Return the current capacity. Returns N while using inline storage, or the heap capacity otherwise.
Definition at line 240 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 209 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 221 of file small_vector.h.
|
inlinenoexcept |
Remove all elements and release heap storage (if any). After clear(), the vector returns to inline storage mode.
Definition at line 259 of file small_vector.h.
|
inlinenoexcept |
Return a pointer to the underlying element storage.
Definition at line 194 of file small_vector.h.
|
inlinenoexcept |
Return a pointer to the underlying element storage.
Definition at line 190 of file small_vector.h.
|
inline |
Construct an element in-place at the end.
| args | Arguments forwarded to the element constructor. |
Definition at line 280 of file small_vector.h.
|
inlinenoexcept |
Check whether the vector is empty.
Definition at line 228 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 217 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 213 of file small_vector.h.
|
inline |
Erase the element at pos. Elements after pos are shifted left. Returns an iterator to the element that now occupies the erased position (or end() if the last element was erased).
| pos | Iterator to the element to erase. |
Definition at line 370 of file small_vector.h.
|
inline |
Access the first element.
Definition at line 173 of file small_vector.h.
|
inline |
Access the first element.
Definition at line 177 of file small_vector.h.
|
inline |
Remove the last element.
Definition at line 306 of file small_vector.h.
|
inline |
Append a copy of value.
Definition at line 265 of file small_vector.h.
|
inline |
Append value by moving.
Definition at line 269 of file small_vector.h.
|
inline |
Reserve capacity for at least newCap elements. If newCap > N, transitions to heap storage. Once on heap, capacity is preserved until clear().
Definition at line 249 of file small_vector.h.
|
inline |
Resize the vector to count elements, default-constructing new elements if growing.
| count | The desired number of elements. |
Definition at line 319 of file small_vector.h.
|
inline |
Resize the vector to count elements, copy-constructing new elements from value if growing.
| count | The desired number of elements. |
| value | The value to copy into new elements. |
Definition at line 344 of file small_vector.h.
|
inlinenoexcept |
Return the number of elements.
Definition at line 232 of file small_vector.h.