Typedef sequant::eval::ValueNodeMap

Typedef Documentation

template<typename Node>
using sequant::eval::ValueNodeMap = std::unordered_map<std::size_t, Node const*>

The map type both bridges below return: a key -> a non-owning pointer to a node of the caller’s forest.

The pointer is what keeps the bridge cheap. FullBinaryNode's copy constructor deep-copies the whole subtree, so a by-value map costs O(nodes x subtree) memory &#8212; measured on a synthetic left-folded Sum spine at 1.8 GB for 500 terms, 6.9 GB for 1000 and 15.7 GB for 2000, OOM past that &#8212; for data the forest already holds.

Warning

Non-owning: the map is only valid while the forest it was built from is alive and unmodified (a node’s children may be replaced in place through FullBinaryNode::left() / right(), which would leave these pointers addressing replaced subtrees). Every builder in this library satisfies both: the forest is a parameter of the enclosing call (evaluate_ordered_schedule and friends), the map is a local of that same call, and nothing in between mutates the forest.