|
|
| SmallVector () noexcept |
| | Constructs an empty SmallVector.
|
| | SmallVector (std::initializer_list< T > init) |
| | Constructs a SmallVector with the elements from the initializer list.
|
|
| ~SmallVector () |
| | Destructor for SmallVector.
|
| | SmallVector (const SmallVector &other) |
| | Copy constructor.
|
| SmallVector & | operator= (const SmallVector &other) |
| | Copy assignment operator.
|
| | SmallVector (SmallVector &&other) noexcept |
| | Move constructor.
|
| SmallVector & | operator= (SmallVector &&other) noexcept |
| | Move assignment operator.
|
| void | push_back (const T &value) |
| | Adds an element to the end of the vector.
|
| template<typename... Args> |
| T & | emplace_back (Args &&... args) |
| | Constructs an element in-place at the end of the vector.
|
|
void | pop_back () noexcept |
| | Removes the last element from the vector.
|
| iterator | insert (const_iterator pos, const T &value) |
| | Inserts an element at the specified position.
|
|
void | clear () noexcept |
| | Clears the contents of the vector.
|
|
T * | data () noexcept |
| | Gets the data stored in the vector.
|
|
const T * | data () const noexcept |
| | Gets the data stored in the vector (const version).
|
|
std::size_t | size () const noexcept |
| | Returns the number of elements in the vector.
|
|
std::size_t | capacity () const noexcept |
| | Returns the capacity of the vector.
|
| bool | empty () const noexcept |
| | Checks if the vector is empty.
|
| T & | operator[] (std::size_t index) noexcept(false) |
| | Accesses the element at the specified index.
|
| const T & | operator[] (std::size_t index) const noexcept(false) |
| | Accesses the element at the specified index (const version).
|
|
iterator | begin () noexcept |
| | Returns an iterator to the beginning of the vector.
|
|
iterator | end () noexcept |
| | Returns an iterator to the end of the vector.
|
|
const_iterator | begin () const noexcept |
| | Returns a const iterator to the beginning of the vector.
|
|
const_iterator | end () const noexcept |
| | Returns a const iterator to the end of the vector.
|
template<typename T, std::size_t DefaultSize>
class donner::SmallVector< T, DefaultSize >
A vector with small-size optimization.
This vector can store a small number of elements on the stack. If the number of elements exceeds the stack capacity, it will allocate memory on the heap. This can reduce memory allocations for small vectors.
- Template Parameters
-
| T | Type of elements stored in the vector. |
| DefaultSize | Number of elements that can be stored on the stack. |