diff --git a/file.hpp b/file.hpp index 1128ac1..060908c 100644 --- a/file.hpp +++ b/file.hpp @@ -30,16 +30,19 @@ public: // Hopefully with sizes two_lines split(line *l, count_type k) { if(l == nullptr) return {nullptr, nullptr}; + // TODO ??????? sizes dont add up if(get_size(l->left) >= k) { // In the left subtree auto two = split(l->left, k); + l->left = two.second; l->size -= get_size(two.first); return {two.first, l}; } else { // In the right subtree auto two = split(l->right, k - (1+get_size(l->left))); + l->right = two.first; l->size -= get_size(two.second); return {l, two.second}; } @@ -104,8 +107,8 @@ public: } // Line removal void remove(count_type k) { - auto two = split(root, k); - two.first = split(two.first, k-1).first; + auto two = split(root, k+1); + two.first = split(two.first, k).first; join(two); } };