From 1e1a147116d77f1b0eea98da45533316eef3cb27 Mon Sep 17 00:00:00 2001 From: Matuush Date: Fri, 28 Mar 2025 16:37:45 +0100 Subject: [PATCH] Fix line finding --- file.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/file.hpp b/file.hpp index ae34101..0eaac96 100644 --- a/file.hpp +++ b/file.hpp @@ -18,6 +18,7 @@ struct line { // Treap representation of a file class file { +public: line* root; // Get size uf a subtreap @@ -66,12 +67,12 @@ class file { line* find(line* l, count_type k) { if(l == nullptr) return nullptr; - if(k >= get_size(l->left)) + if(k <= get_size(l->left)) return find(l->left, k); - else if(k > l->size+1) - return find(l->right, k - (1+get_size(l->left)) ); - else + else if(k == get_size(l->left)+1) return l; + else + return find(l->right, k - (1+get_size(l->left)) ); } public: @@ -97,7 +98,7 @@ public: } auto two = split(root, k); - join(two.first, l); + two.first = join(two.first, l); join(two); } // Line removal