Remove unused option not to remember node version after update
This commit is contained in:
parent
131a0d3384
commit
02dc2b9d7c
2 changed files with 14 additions and 27 deletions
|
@ -67,7 +67,7 @@ class Treap {
|
|||
|
||||
line* insert(line *l, count_type k, string s, bool new_version);
|
||||
line* remove(line *l, count_type k);
|
||||
line* update(line *l, count_type k, string s, bool new_version);
|
||||
line* update(line *l, count_type k, string s);
|
||||
|
||||
line* pick_higher(line *l);
|
||||
void delete_version(line *l);
|
||||
|
@ -95,7 +95,7 @@ public:
|
|||
// Line meta-operations
|
||||
void insert(count_type k, string s, bool new_version = true);
|
||||
void remove(count_type k);
|
||||
void update(count_type k, string s, bool new_version = true);
|
||||
void update(count_type k, string s);
|
||||
|
||||
// Other line operations
|
||||
void split_line(position p, bool should_compress = true);
|
||||
|
|
23
treap.cpp
23
treap.cpp
|
@ -122,29 +122,18 @@ line* Treap::remove(line *l, count_type k) {
|
|||
return new line(l->priority, l->text, lson, son, son);
|
||||
}
|
||||
}
|
||||
line* Treap::update(line *l, count_type k, string s, bool new_version) {
|
||||
if(new_version) {
|
||||
line* Treap::update(line *l, count_type k, string s) {
|
||||
if(k < get_size(l->left)) {
|
||||
line *son = update(l->left, k, s, new_version);
|
||||
line *son = update(l->left, k, s);
|
||||
return new line(l->priority, l->text, son, l->right, son);
|
||||
}
|
||||
else if(k == get_size(l->left))
|
||||
return new line(l->priority, s, l->left, l->right, nullptr);
|
||||
else {
|
||||
line *son = update(l->right, k - (1+get_size(l->left)), s, new_version);
|
||||
line *son = update(l->right, k - (1+get_size(l->left)), s);
|
||||
return new line(l->priority, l->text, l->left, son, son);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(k < get_size(l->left))
|
||||
update(l->left, k, s, new_version);
|
||||
else if(k == get_size(l->left))
|
||||
l->text = s;
|
||||
else
|
||||
update(l->right, k - (1+get_size(l->left)), s, new_version);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Find k-th line of file
|
||||
line* Treap::find(line *l, count_type k) {
|
||||
|
@ -237,7 +226,7 @@ void Treap::remove(count_type k) {
|
|||
}
|
||||
|
||||
// Line text update
|
||||
void Treap::update(count_type k, string s, bool new_version) {
|
||||
void Treap::update(count_type k, string s) {
|
||||
if(k >= size()) {
|
||||
std::cerr << "Updating out of file range\n";
|
||||
return;
|
||||
|
@ -246,13 +235,11 @@ void Treap::update(count_type k, string s, bool new_version) {
|
|||
if(s == find(get_root(), k)->text)
|
||||
return;
|
||||
|
||||
line *new_root = update(get_root(), k, s, new_version);
|
||||
line *new_root = update(get_root(), k, s);
|
||||
|
||||
if(new_version) {
|
||||
root.push(new_root);
|
||||
changes.push({k, 1});
|
||||
}
|
||||
}
|
||||
|
||||
// Accessing the file
|
||||
string Treap::get_line(count_type r, bool substitute_tab) {
|
||||
|
|
Loading…
Reference in a new issue