#include <GGUI/Public/NodeRows.h>
template<typename T>
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
slotin 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
slotis 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.removemay change the value first; it stays in the freed slot. - void RemoveAll(NodeIndex node)
- Remove all the node's values.