|
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
|
Growable array of T whose growth can fail. More...
#include <deki/providers/Vector.h>
Public Member Functions | |
| Vector (Memory::Region region, AllocContext ctx={}) | |
| Takes the memory region the storage lives in. | |
| Vector ()=delete | |
| ~Vector ()=default | |
| Vector (Vector &&other) noexcept | |
| Vector & | operator= (Vector &&other) noexcept |
| Vector (const Vector &)=delete | |
| Vector & | operator= (const Vector &)=delete |
| bool | Reserve (size_t count) |
| Makes room for at least count elements in the constructor's region. | |
| bool | PushBack (const T &value) |
| Appends a copy of value, growing if needed. | |
| bool | PopBack () |
| Drops the last element. False when there was none. | |
| bool | RemoveUnordered (size_t index) |
| Removes the element at index and moves the last one into its place. | |
| void | Clear () |
| Empties the vector and keeps the memory, for refilling every frame. | |
| void | Reset () |
| Empties the vector and frees the memory. | |
| size_t | Size () const |
| size_t | Capacity () const |
| bool | Empty () const |
| T * | Data () |
| const T * | Data () const |
| T & | operator[] (size_t i) |
| const T & | operator[] (size_t i) const |
| T * | begin () |
| T * | end () |
| const T * | begin () const |
| const T * | end () const |
| T & | Back () |
| The last element. The vector must not be empty. | |
| const T & | Back () const |
Growable array of T whose growth can fail.
Move-only, like Buffer: copying needs a second allocation that can fail, and a copy constructor cannot report that.
T must be trivially copyable and trivially destructible, which Buffer enforces. Growth moves elements with memcpy and destruction just frees the block, so these are lists of plain structs and handles.
|
inlineexplicit |
Takes the memory region the storage lives in.
Required: the engine does not pick a region, so the declaration says what memory this list uses.
|
delete |
|
default |
|
inlinenoexcept |
|
delete |
|
inlinenoexcept |
|
delete |
|
inline |
Makes room for at least count elements in the constructor's region.
Call it once up front, where a failure is easy to handle; the PushBack calls within that capacity then cannot fail. Never shrinks. Returns true when the capacity is already enough.
|
inline |
Appends a copy of value, growing if needed.
Returns false when it could not grow; the vector is then unchanged.
Growth doubles (amortised O(1)) from a first block of 4. The first block is small because a device project has many short lists.
|
inline |
Drops the last element. False when there was none.
|
inline |
Removes the element at index and moves the last one into its place.
O(1) but changes the order, like ParticlePool's KillSwap. Returns false when index is out of range. To keep the order, rebuild the list.
|
inline |
Empties the vector and keeps the memory, for refilling every frame.
|
inline |
Empties the vector and frees the memory.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
The last element. The vector must not be empty.
|
inline |