From 05426f95c7212afb6f2928b385de881f44f655cc Mon Sep 17 00:00:00 2001 From: caterpillow <50687461+caterpillow@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:27:53 +1100 Subject: [PATCH] Update byot.html --- byot.html | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/byot.html b/byot.html index 7de3741..e6c6704 100644 --- a/byot.html +++ b/byot.html @@ -91,6 +91,7 @@

Build your own treap!




+


@@ -189,6 +190,7 @@

Build your own treap!

let del_option = false; let size_option = false; let spliti_option = false; + let findi_option = false; let three_spliti_option = false; let insi_option = false; let deli_option = false; @@ -233,6 +235,7 @@

Build your own treap!

["ins_option", "split_option"], ["spliti_option", "size_option"], ["insi_option", "spliti_option"], + ["findi_option", "size_option"], ["range_add", "lazy_prop"], ["range_set", "lazy_prop"], ["key_add", "lazy_prop"], @@ -401,6 +404,7 @@

Build your own treap!

split_option = document.getElementById("split_option").checked; three_split_option = document.getElementById("three_split_option").checked; find_option = document.getElementById("find_option").checked; + findi_option = document.getElementById("findi_option").checked; ins_option = document.getElementById("ins_option").checked; del_option = document.getElementById("del_option").checked; size_option = document.getElementById("size_option").checked; @@ -743,14 +747,25 @@

Build your own treap!

} if (find_option) { - code += `bool find(ptr n, ${key_type} k) {\n` + - ' if (!n) return false;\n' + - ' if (n->key == k) return true;\n' + + code += 'ptr find(ptr n, int k) {\n' + + ' if (!n) return 0;\n' + if (push) code += ' push(n);\n'; + code += ' if (n->key == k) return n;\n' + ' if (k <= n->key) return find(n->l, k);\n' + ' else return find(n->r, k);\n' + '}\n\n' } + if (findi_option) { + code += 'ptr findi(ptr n, int i) {\n' + + ' if (!n) return 0;\n' + if (push) code += ' push(n);\n' + code += ' if (sz(n->l) == i) return n;\n' + + ' if (i < sz(n->l)) return findi(n->l, i);\n' + + ' else return findi(n->r, i - sz(n->l) - 1);\n' + + '}\n\n' + } + if (ins_option) { if (comments) code += '// returns root of new treap. only insert single nodes\n' code += 'ptr ins(ptr n, ptr it) {\n' +