![]() |
ImFusion C++ SDK 4.5.0
|
#include <ImFusion/Core/SmallVector.h>
A small-buffer-optimized variant of std::vector that stores up to N elements without heap allocation. More...
A small-buffer-optimized variant of std::vector that stores up to N elements without heap allocation.
When the number of elements grows beyond N a heap allocation is used so that SmallVector behaves like a regular std::vector. Use this container when the number of elements is usually small and short-lived, but can occasionally grow dynamically. Typical examples are temporary working sets, per-frame buffers, or collections built in tight loops where avoiding frequent heap allocations improves performance.
Prefer SmallVector over std::vector if:
Prefer std::vector if:
Example:
| T | Element type |
| N | Maximum number of elements stored inline without heap allocation |
Public Types | |
| using | value_type = T |
| using | size_type = std::size_t |
| using | iterator = T* |
| using | const_iterator = const T* |
Public Member Functions | |
| SmallVector (const SmallVector &other) | |
| SmallVector (SmallVector &&other) noexcept(std::is_nothrow_move_constructible< T >::value) | |
| SmallVector & | operator= (const SmallVector &other) |
| SmallVector & | operator= (SmallVector &&other) noexcept(std::is_nothrow_move_constructible< T >::value) |
| T & | operator[] (size_type i) |
| const T & | operator[] (size_type i) const |
| T * | data () noexcept |
| const T * | data () const noexcept |
| T & | front () |
| const T & | front () const |
| T & | back () |
| const T & | back () const |
| size_type | size () const noexcept |
| size_type | capacity () const noexcept |
| bool | isEmpty () const noexcept |
| void | push_back (const T &value) |
| void | push_back (T &&value) |
| template<typename... Args> | |
| T & | emplace_back (Args &&... args) |
| iterator | insert (const_iterator pos, const T &value) |
| iterator | insert (const_iterator pos, T &&value) |
| void | pop_back () |
| iterator | erase (const_iterator pos) |
| void | clear () noexcept |
| void | reserve (size_type newCap) |
| void | resize (size_type newSize) |
| void | shrink_to_fit () |
| iterator | begin () noexcept |
| iterator | end () noexcept |
| const_iterator | begin () const noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cbegin () const noexcept |
| const_iterator | cend () const noexcept |