|
dispenso 1.6.2
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 50 of file small_vector.h.
|
inlinenoexcept |
Construct an empty SmallVector.
Definition at line 68 of file small_vector.h.
|
inlineexplicit |
Construct a SmallVector with count default-constructed elements.
| count | The number of elements. |
Definition at line 75 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 85 of file small_vector.h.
|
inline |
Construct a SmallVector from an initializer list.
| init | The initializer list of elements. |
Definition at line 94 of file small_vector.h.
|
inline |
Copy constructor.
Definition at line 102 of file small_vector.h.
|
inlinenoexcept |
Move constructor. Moves elements and leaves other empty.
Definition at line 110 of file small_vector.h.
|
inline |
Definition at line 128 of file small_vector.h.
|
inline |
Access the last element.
Definition at line 192 of file small_vector.h.
|
inline |
Access the last element.
Definition at line 196 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 216 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 212 of file small_vector.h.
|
inlinenoexcept |
Return the current capacity. Returns N while using inline storage, or the heap capacity otherwise.
Definition at line 251 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 220 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 232 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 270 of file small_vector.h.
|
inlinenoexcept |
Return a pointer to the underlying element storage.
Definition at line 205 of file small_vector.h.
|
inlinenoexcept |
Return a pointer to the underlying element storage.
Definition at line 201 of file small_vector.h.
|
inline |
Construct an element in-place at the end.
| args | Arguments forwarded to the element constructor. |
Definition at line 291 of file small_vector.h.
|
inlinenoexcept |
Check whether the vector is empty.
Definition at line 239 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 228 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 224 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 381 of file small_vector.h.
|
inline |
Access the first element.
Definition at line 184 of file small_vector.h.
|
inline |
Access the first element.
Definition at line 188 of file small_vector.h.
|
inline |
Remove the last element.
Definition at line 317 of file small_vector.h.
|
inline |
Append a copy of value.
Definition at line 276 of file small_vector.h.
|
inline |
Append value by moving.
Definition at line 280 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 260 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 330 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 355 of file small_vector.h.
|
inlinenoexcept |
Return the number of elements.
Definition at line 243 of file small_vector.h.