package toffee
Build not yet checkedInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=a92cbbcbe016fb19fb0a749222da0e459a9567aef3f4c7340d9bd6b71c53ed6f
sha512=6a7ab054605538bb31a2b73a1a6d093981a2704c9f0af5852221c05735290d74aca7c7282298c4d0f91e86a800e2ccd94b4918af883cd963449c758eb6b272b3
doc/toffee.tree/Toffee_tree/Node_id/index.html
Module Toffee_tree.Node_idSource
Unique identifier for nodes in a layout tree.
Node identifiers use a generational index scheme to prevent use-after-free errors. Each identifier contains an index (position in the tree's internal storage) and a generation number (incremented when the slot is reused). This detects stale references to removed nodes.
Invariants:
- Two identifiers are equal only if both index and generation match.
- Generation numbers monotonically increase for each index slot.
- A node identifier becomes invalid when its node is removed from the tree.
make index creates a node identifier with generation 0.
Used by the tree when allocating new nodes.
make_with_generation index generation creates a node identifier with the specified index and generation.
Used by the tree when reusing freed node slots with incremented generation.
to_int node_id returns the index component.
Discards the generation. Use only for indexing into internal storage after validating the full identifier.
generation node_id returns the generation component.
Used by the tree to detect stale references when validating identifiers.
equal lhs rhs tests if two identifiers reference the same node.
Returns true only if both index and generation match.
compare lhs rhs orders identifiers lexicographically by index, then generation.
Enables use in ordered data structures like Map and Set.
pp fmt node_id prints the identifier as NodeId(index,generation).