From 713f4c6eb6f55520e39bf7100b2e58ce65268468 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 30 Apr 2021 19:47:54 -0700 Subject: tree: new functions for reseting iterator. * tree.c (tree_reset, tree_reset_at): New functions. (tree_init): tree-reset and tree-reset-at intrinsics registered. * tree.h (tree_reset, tree_reset_at): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated. --- tests/010/tree.tl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/010') diff --git a/tests/010/tree.tl b/tests/010/tree.tl index 83b3172c..fde11300 100644 --- a/tests/010/tree.tl +++ b/tests/010/tree.tl @@ -40,6 +40,14 @@ (add (key n)))) (range 0 19)) +(vtest (build (for* ((j (tree-begin tr)) + (i (progn (tree-next j) (tree-next j) (tree-reset j tr))) + (n (tree-next i))) + (n) + ((set n (tree-next i))) + (add (key n)))) + (range 0 19)) + (defvarl trc (copy-search-tree tr)) (vtest trc tr) @@ -71,6 +79,13 @@ (add (key n)))) (range 8 19)) +(vtest (build (for* ((i (tree-reset-at (tree-begin #T(())) tr 8)) + (n (tree-next i))) + (n) + ((set n (tree-next i))) + (add (key n)))) + (range 8 19)) + (test (tree-next (tree-begin-at tr 20)) nil) (test (tree-next (tree-begin-at #T(()) 0)) nil) -- cgit v1.2.3