summaryrefslogtreecommitdiffstats
path: root/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tree.c b/tree.c
index 9a7044f0..47bbe8d6 100644
--- a/tree.c
+++ b/tree.c
@@ -711,6 +711,18 @@ val copy_search_tree(val tree)
return ntree;
}
+val make_similar_tree(val tree)
+{
+ val self = lit("make-similar-tree");
+ struct tree *ntr = coerce(struct tree *, malloc(sizeof *ntr));
+ struct tree *otr = coerce(struct tree *, cobj_handle(self, tree, tree_s));
+ val ntree = cobj(coerce(mem_t *, ntr), tree_s, &tree_ops);
+ *ntr = *otr;
+ ntr->root = nil;
+ ntr->size = ntr->max_size = 0;
+ return ntree;
+}
+
val treep(val obj)
{
return tnil(type(obj) == COBJ && obj->co.cls == tree_s);
@@ -834,6 +846,7 @@ void tree_init(void)
reg_fun(tree_s, func_n4o(tree, 0));
reg_fun(tree_construct_s, func_n2(tree_construct));
reg_fun(intern(lit("copy-search-tree"), user_package), func_n1(copy_search_tree));
+ reg_fun(intern(lit("make-similar-tree"), user_package), func_n1(make_similar_tree));
reg_fun(intern(lit("treep"), user_package), func_n1(treep));
reg_fun(intern(lit("tree-insert-node"), user_package), func_n2(tree_insert_node));
reg_fun(intern(lit("tree-insert"), user_package), func_n2(tree_insert));