Skip to contents

A hash of a tree's structure – node kinds, child structure, leaf positions, names, and the class and aux data of each object of a class registered with register_tree_node() – consistent with tree_equal(): trees that are tree_equal() hash to the same value. Intended as a cache key for tree-structured dispatch within a session: a class folds in by the address of its registration, so the hash of a tree with registered objects differs between sessions.

Usage

tree_hash(tree)

Arguments

tree

(RTree)
A tree as returned by build_tree().

Value

character(1), the structural hash.

Examples

tree_hash(build_tree(list(a = 1))) == tree_hash(build_tree(list(a = 2)))
#> [1] TRUE
tree_hash(build_tree(list(a = 1))) == tree_hash(build_tree(list(b = 1)))
#> [1] FALSE