AngouriMath

Navigation

NodeStack


← Back to list of classes

Description

Summary

The pre-order walk behind Nodes: the node, then each child's walk in
order, kept on an explicit stack rented from Shared.

Remarks

It allocates nothing, per node or per walk, and keeps nothing on the tree. A chain of
LINQ iterators costs an iterator per node per enumeration, and caching it on every
node keeps that chain alive as long as the node; caching the walk's result instead is
quadratic in memory, since every node would hold its whole subtree (31 MB on a sum of
2000 terms).
#534
Every walk has its own stack, so a predicate that walks another tree while this one
is being walked, on this thread or another, shares nothing with it. A walk that is
abandoned without Release only fails to give its array back to the
pool. It is a mutable struct: copying one mid-walk would share the array, so it is
only ever held in a local or in NodeWalk.

Members

























Angouri © 2019-2026 · Project's repo · Site's repo · Octicons · Transparency · 6003 pages online