summaryrefslogtreecommitdiff
path: root/content/datastructures/persistent.cpp
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2024-07-30 23:58:19 +0200
committermzuenni <michi.zuendorf@gmail.com>2024-07-30 23:58:35 +0200
commitd7905f7dec9e306d7d6f907ce35abc40f24af1c5 (patch)
treed2275dca21776ce7c808307d6e18b228a36d77a5 /content/datastructures/persistent.cpp
parentb79123a4da8eb3c1aec30c4c03abf032daa0f1b1 (diff)
more tests
Diffstat (limited to 'content/datastructures/persistent.cpp')
-rw-r--r--content/datastructures/persistent.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/content/datastructures/persistent.cpp b/content/datastructures/persistent.cpp
index 4093cdc..7d15342 100644
--- a/content/datastructures/persistent.cpp
+++ b/content/datastructures/persistent.cpp
@@ -4,15 +4,15 @@ struct persistent {
vector<pair<int, T>> data;
persistent(int& time, T value = {})
- : time(time), data(1, {time, value}) {}
+ : time(time), data(1, {2*time, value}) {}
T get(int t) {
- return prev(upper_bound(all(data), pair{t+1, T{}}))->second;
+ return prev(upper_bound(all(data), pair{2*t+1, T{}}))->second;
}
int set(T value) {
- time += 2;
- data.push_back({time, value});
+ time++;
+ data.push_back({2*time, value});
return time;
}
};