Class that implements the children and withNewChildren methods using reflection when implementing
TreeNode with a case class or case object.
Applies the given partial function starting from the leafs of this tree.
Applies the given partial function starting from the root of this tree.
Applies the given partial function starting from the root of this tree.
Note the applied rule cannot insert new parent nodes.
This is the basic tree node class.
This is the basic tree node class. Usually it makes more sense to use AbstractTreeNode, which uses reflection
to generate the children and withNewChildren field/method. Our benchmarks show that manually implementing
them can result in a speedup of a factor of ~3 for tree rewrites, so in performance critical places it might
make sense to extend TreeNode instead.
This class uses array operations instead of Scala collections, both for improved performance as well as to save stack frames during recursion, which allows it to operate on trees that are several thousand nodes high.
Caches an instance of the copy method per case class type.
Class that implements the
childrenandwithNewChildrenmethods using reflection when implementingTreeNodewith a case class or case object.Requirements: All child nodes need to be individual constructor parameters and their order in children is their order in the constructor. Every constructor parameter of type
Tis assumed to be a child node.This class caches values that are expensive to recompute.
The constructor can also contain a list of children, but there are constraints:
withNewChildrenwith a different number of children than the original node had and vary the length of the list to accommodate.