template<typename T>
GGUI::NodeChain class

NodeChain<T>: a short list of values per node.

Values live in one pool; each node's values form a linked chain starting from the node's row. Operations cost the chain's length regardless of tree size, and the pool can still be iterated whole.

A freed slot keeps its value, so a value can hold a generation that outlives each use.

Public static variables

static uint32_t NoSlot constexpr
the end of a chain

Public functions

auto First(NodeIndex node) const -> uint32_t
The node's first slot, or NoSlot.
auto Next(uint32_t slot) const -> uint32_t
The slot after slot in its node's chain, or NoSlot.
auto operator[](uint32_t slot) -> T&
The value in slot.
auto operator[](uint32_t slot) const -> const T&
The value in slot.
auto IsUsed(uint32_t slot) const -> bool
Whether slot is in a chain now.
auto SlotCount() const -> uint32_t
Slots ever allocated: iterate [0, SlotCount) and skip unused ones to visit everything.
auto Count() const -> uint32_t
How many slots are in chains.
auto Bytes() const -> size_t
Memory held, excluding anything the values own.
auto Add(NodeIndex node) -> uint32_t
Append a slot to the node's chain and return it. Its value is whatever the slot last held.
template<typename TFn>
void RemoveIf(NodeIndex node, TFn&& remove)
Remove the node's values for which remove(value) is true. remove may change the value first; it stays in the freed slot.
void RemoveAll(NodeIndex node)
Remove all the node's values.