package toffee
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/toffee.tree/Tree/Node_id/index.html
Module 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).