diff --git a/file.hpp b/file.hpp index b1bd35b..ae34101 100644 --- a/file.hpp +++ b/file.hpp @@ -4,7 +4,6 @@ using std::string; typedef unsigned long long count_type; -#define RAND_MAX (1 << 62) class line; typedef std::pair two_lines; @@ -35,13 +34,13 @@ class file { if(get_size(l->left) > k) { // In the left subtree auto two = split(l->left, k); - l->size -= two.first->size; + 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->size -= two.second->size; + l->size -= get_size(two.second); return {l, two.second}; } } @@ -80,6 +79,7 @@ public: srand(120); root = nullptr; } + // File access // Don't find index k, but k-th line -> +1 line* find(count_type k) { if(k >= root->size) @@ -87,7 +87,7 @@ public: return find(root, k+1); } - // File access + // Line insert void insert(int k, string s) { line *l = new line(rand(), s);