|
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
|
Growable array of T whose growth can fail. More...
#include <deki/providers/Vector.h>
Public Member Functions | |
| Vector ()=delete | |
| Vector (const Vector &)=delete | |
| Vector (Memory::Region region, AllocContext ctx={}) | |
| Takes the memory region the storage lives in. | |
| Vector (Vector &&other) noexcept | |
| ~Vector ()=default | |
| T & | Back () |
| The last element. The vector must not be empty. | |
| const T & | Back () const |
| T * | begin () |
| const T * | begin () const |
| size_t | Capacity () const |
| void | Clear () |
| Empties the vector and keeps the memory, for refilling every frame. | |
| T * | Data () |
| const T * | Data () const |
| bool | Empty () const |
| T * | end () |
| const T * | end () const |
| Vector & | operator= (const Vector &)=delete |
| Vector & | operator= (Vector &&other) noexcept |
| T & | operator[] (size_t i) |
| const T & | operator[] (size_t i) const |
| bool | PopBack () |
| Drops the last element. False when there was none. | |
| bool | PushBack (const T &value) |
| Appends a copy of value, growing if needed. | |
| bool | RemoveUnordered (size_t index) |
| Removes the element at index and moves the last one into its place. | |
| bool | Reserve (size_t count) |
| Makes room for at least count elements in the constructor's region. | |
| void | Reset () |
| Empties the vector and frees the memory. | |
| size_t | Size () 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 |
|
inline |
The last element. The vector must not be empty.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Empties the vector and keeps the memory, for refilling every frame.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
delete |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
Drops the last element. False when there was none.
|
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 |
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 |
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 |
Empties the vector and frees the memory.
|
inline |