From 236a11759c4f0ccdd809621a990da2e0ae138def Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 17 Dec 2021 21:49:16 -0800 Subject: tree: support for duplicate keys. * tree.c (tr_insert): New argument for allowing duplicate. If it is true, suppresses the case of replacing a node, causing the logic to fall through to traversing right, so the duplicate key effectively looks like it is greater than the existing duplicates, and gets inserted as the rightmost duplicate. (tr_do_delete_specific, tr_delete_specific): New static functions. (tree_insert_node): New parameter, passed to tr_insert. (tree_insert): New parameter, passed to tree_insert_node. (tree_delete_specific_node): New function. (tree): New parameter to allow duplicate keys in the elements sequence. (tree_construct): Pass t to tree to allow duplicate elements. (tree_init): Update registrations of tree, tree-insert and tree-insert-node. Register tree-delete-specific-node function. * tree.h (tree, tree_insert_node, tree_insert): Declarations updated. (tree_delete_specific_node): Declared. * lib.c (seq): Pass t argument to tree_insert, allowing duplicates. * parser.c (circ_backpatch): Likewise. * parser.y (tree): Pass t to new argument of tree, so duplicates are preserved in the element list of the #T literal. * y.tab.c.shipped: Updated. * tests/010/tree.tl: Test cases for duplicate keys. * txr.1: Documented. * stdlib/doc-syms.tl: Updated. --- stdlib/doc-syms.tl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'stdlib/doc-syms.tl') diff --git a/stdlib/doc-syms.tl b/stdlib/doc-syms.tl index 654a3610..80922b42 100644 --- a/stdlib/doc-syms.tl +++ b/stdlib/doc-syms.tl @@ -2002,8 +2002,10 @@ ("tree-bind" "N-021A9008") ("tree-case" "N-03D834A5") ("tree-clear" "N-03C88274") + ("tree-count" "N-032882F2") ("tree-delete" "N-022035DF") ("tree-delete-node" "N-00772FAE") + ("tree-delete-specific-node" "N-009B02CA") ("tree-find" "N-0149BC05") ("tree-insert" "N-0114FF9E") ("tree-insert-node" "N-008B4AD9") -- cgit v1.2.3