A two-axis table : rows are a dense index (0,1,2... reused, like ecs Entity), columns are Columns... (fixed, known at compile time, one vector<optional<T>> per type — no hashing). Each row also carries an Identity, whatever the caller wants a row to own or be keyed by — a SharedLibrary, a string, anything. Stride does not know or care what Identity is.
More...
#include <Stride.hpp>
|
| Entity | add (Identity identity) |
| | A new row, owning identity. Every column grows (or a freed index is reused).
|
| |
| void | remove (Entity e) |
| | Clears every column at this row and its identity. The index becomes reusable.
|
| |
| std::optional< Identity > & | identity (Entity e) |
| | The Identity owning this row.
|
| |
| template<typename T > |
| void | set (Entity e, T value) |
| | Writes the T value of this row.
|
| |
| template<typename T > |
| std::optional< T > & | at (Entity e) |
| | The T value of this row, or nullopt.
|
| |
| template<typename T > |
| std::vector< std::optional< T > > & | column () |
| | The WHOLE T column — a vector already there, nothing to rebuild.
|
| |
| template<typename F > |
| void | row (Entity e, F &&f) |
| | Visits the WHOLE row, one column at a time. No copy.
|
| |
| size_t | size () const |
| | The number of live rows.
|
| |
template<typename Identity, typename... Columns>
class Stride< Identity, Columns >
A two-axis table : rows are a dense index (0,1,2... reused, like ecs Entity), columns are Columns... (fixed, known at compile time, one vector<optional<T>> per type — no hashing). Each row also carries an Identity, whatever the caller wants a row to own or be keyed by — a SharedLibrary, a string, anything. Stride does not know or care what Identity is.
- Template Parameters
-
| Identity | |
| Columns | Stride<Identity, A, B, C, D> t;
auto e = t.add(Identity{...}); // a new row, owning this identity
t.set<B>(e, B{...}); // fill column B for this row
t.column<B>(); // the WHOLE B column — no copy, no rebuild
t.row(e, visitor); // the WHOLE row e — a fold over Columns..., no copy
t.identity(e); // the Identity of this row
The index is hidden behind Entity : private construction, Stride is the only friend. No way to fabricate an Entity by hand, and an Entity from Stride<X,A,B> is NOT the same type as one from Stride<Y,C,D> — passing it to the wrong Stride is a COMPILE error, not a runtime bug. |
◆ add()
template<typename Identity , typename... Columns>
| Entity Stride< Identity, Columns >::add |
( |
Identity |
identity | ) |
|
|
inline |
A new row, owning identity. Every column grows (or a freed index is reused).
- Parameters
-
- Returns
- Entity
◆ at()
template<typename Identity , typename... Columns>
template<typename T >
| std::optional< T > & Stride< Identity, Columns >::at |
( |
Entity |
e | ) |
|
|
inline |
The T value of this row, or nullopt.
- Template Parameters
-
- Parameters
-
- Returns
- std::optional<T>&
◆ column()
template<typename Identity , typename... Columns>
template<typename T >
| std::vector< std::optional< T > > & Stride< Identity, Columns >::column |
( |
| ) |
|
|
inline |
The WHOLE T column — a vector already there, nothing to rebuild.
- Template Parameters
-
- Returns
- std::vector<std::optional<T>>&
◆ identity()
template<typename Identity , typename... Columns>
| std::optional< Identity > & Stride< Identity, Columns >::identity |
( |
Entity |
e | ) |
|
|
inline |
The Identity owning this row.
- Parameters
-
- Returns
- std::optional<Identity>&
◆ remove()
template<typename Identity , typename... Columns>
Clears every column at this row and its identity. The index becomes reusable.
- Parameters
-
◆ row()
template<typename Identity , typename... Columns>
template<typename F >
Visits the WHOLE row, one column at a time. No copy.
- Template Parameters
-
- Parameters
-
◆ set()
template<typename Identity , typename... Columns>
template<typename T >
Writes the T value of this row.
- Template Parameters
-
- Parameters
-
◆ size()
template<typename Identity , typename... Columns>
| size_t Stride< Identity, Columns >::size |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: