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) {