From 7ca8b1a3cb764fbc087a18218a42b159da13f1cc Mon Sep 17 00:00:00 2001 From: Matuush Date: Wed, 9 Apr 2025 08:00:51 +0200 Subject: [PATCH] Add treap clearing --- treap.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/treap.hpp b/treap.hpp index 2f14e46..63f0c93 100644 --- a/treap.hpp +++ b/treap.hpp @@ -89,6 +89,13 @@ public: // Don't find index k, but k-th line -> +1 return find(root, k+1); } + void clear() { + while(size() > 0) { + auto two = split(root, 0); + root = two.second; + delete two.first; + } + } // Line insert void insert(int k, string s) {