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* insert(line *l, count_type k, string s, bool new_version);
|
||||||
line* remove(line *l, count_type k);
|
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);
|
line* pick_higher(line *l);
|
||||||
void delete_version(line *l);
|
void delete_version(line *l);
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
// Line meta-operations
|
// Line meta-operations
|
||||||
void insert(count_type k, string s, bool new_version = true);
|
void insert(count_type k, string s, bool new_version = true);
|
||||||
void remove(count_type k);
|
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
|
// Other line operations
|
||||||
void split_line(position p, bool should_compress = true);
|
void split_line(position p, bool should_compress = true);
|
||||||
|
|
37
treap.cpp
37
treap.cpp
|
@ -122,27 +122,16 @@ line* Treap::remove(line *l, count_type k) {
|
||||||
return new line(l->priority, l->text, lson, son, son);
|
return new line(l->priority, l->text, lson, son, son);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line* Treap::update(line *l, count_type k, string s, bool new_version) {
|
line* Treap::update(line *l, count_type k, string s) {
|
||||||
if(new_version) {
|
if(k < get_size(l->left)) {
|
||||||
if(k < get_size(l->left)) {
|
line *son = update(l->left, k, s);
|
||||||
line *son = update(l->left, k, s, new_version);
|
return new line(l->priority, l->text, son, l->right, son);
|
||||||
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);
|
|
||||||
return new line(l->priority, l->text, l->left, son, son);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if(k == get_size(l->left))
|
||||||
|
return new line(l->priority, s, l->left, l->right, nullptr);
|
||||||
else {
|
else {
|
||||||
if(k < get_size(l->left))
|
line *son = update(l->right, k - (1+get_size(l->left)), s);
|
||||||
update(l->left, k, s, new_version);
|
return new line(l->priority, l->text, l->left, son, son);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +226,7 @@ void Treap::remove(count_type k) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line text update
|
// 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()) {
|
if(k >= size()) {
|
||||||
std::cerr << "Updating out of file range\n";
|
std::cerr << "Updating out of file range\n";
|
||||||
return;
|
return;
|
||||||
|
@ -246,12 +235,10 @@ void Treap::update(count_type k, string s, bool new_version) {
|
||||||
if(s == find(get_root(), k)->text)
|
if(s == find(get_root(), k)->text)
|
||||||
return;
|
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);
|
||||||
root.push(new_root);
|
changes.push({k, 1});
|
||||||
changes.push({k, 1});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessing the file
|
// Accessing the file
|
||||||
|
|
Loading…
Reference in a new issue