|
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 51 of file small_vector.h.
|
inlinenoexcept |
Construct an empty SmallVector.
Definition at line 69 of file small_vector.h.
|
inlineexplicit |
Construct a SmallVector with count default-constructed elements.
| count | The number of elements. |
Definition at line 76 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 86 of file small_vector.h.
|
inline |
Construct a SmallVector from an initializer list.
| init | The initializer list of elements. |
Definition at line 95 of file small_vector.h.
|
inline |
Copy constructor.
Definition at line 105 of file small_vector.h.
|
inlinenoexcept |
Move constructor. Moves elements and leaves other empty.
Definition at line 115 of file small_vector.h.
|
inline |
Definition at line 133 of file small_vector.h.
|
inline |
Access the last element.
Definition at line 197 of file small_vector.h.
|
inline |
Access the last element.
Definition at line 201 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 221 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 217 of file small_vector.h.
|
inlinenoexcept |
Return the current capacity. Returns N while using inline storage, or the heap capacity otherwise.
Definition at line 256 of file small_vector.h.
|
inlinenoexcept |
Return an iterator to the first element.
Definition at line 225 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 237 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 275 of file small_vector.h.
|
inlinenoexcept |
Return a pointer to the underlying element storage.
Definition at line 210 of file small_vector.h.
|
inlinenoexcept |
Return a pointer to the underlying element storage.
Definition at line 206 of file small_vector.h.
|
inline |
Construct an element in-place at the end.
| args | Arguments forwarded to the element constructor. |
Definition at line 296 of file small_vector.h.
|
inlinenoexcept |
Check whether the vector is empty.
Definition at line 244 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 233 of file small_vector.h.
|
inlinenoexcept |
Return an iterator past the last element.
Definition at line 229 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 386 of file small_vector.h.
|
inline |
Access the first element.
Definition at line 189 of file small_vector.h.
|
inline |
Access the first element.
Definition at line 193 of file small_vector.h.
|
inline |
Remove the last element.
Definition at line 321 of file small_vector.h.
|
inline |
Append a copy of value.
Definition at line 281 of file small_vector.h.
|
inline |
Append value by moving.
Definition at line 285 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 265 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 334 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 356 of file small_vector.h.
|
inlinenoexcept |
Return the number of elements.
Definition at line 248 of file small_vector.h.