aboutsummaryrefslogtreecommitdiff
path: root/src/util/crdt/lww_map.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-05-06 17:14:09 +0200
committerAlex Auvolat <alex@adnab.me>2022-05-10 13:25:10 +0200
commitdd54d0b2b13ecf1f95e60b107de9af20632335f6 (patch)
treeb90ae9da1fa9c1c7cad20f98f1eb77888b3f8b1f /src/util/crdt/lww_map.rs
parent01c4876fb447b70106e934ad09cf9b921f33682a (diff)
downloadgarage-dd54d0b2b13ecf1f95e60b107de9af20632335f6.tar.gz
garage-dd54d0b2b13ecf1f95e60b107de9af20632335f6.zip
Refactor code for apply/revert, implement Update/Apply/RevertLayout
Diffstat (limited to 'src/util/crdt/lww_map.rs')
-rw-r--r--src/util/crdt/lww_map.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/crdt/lww_map.rs b/src/util/crdt/lww_map.rs
index c155c3a8..91d24c7f 100644
--- a/src/util/crdt/lww_map.rs
+++ b/src/util/crdt/lww_map.rs
@@ -140,6 +140,11 @@ where
self.vals.clear();
}
+ /// Retain only values that match a certain predicate
+ pub fn retain(&mut self, pred: impl FnMut(&(K, u64, V)) -> bool) {
+ self.vals.retain(pred);
+ }
+
/// Get a reference to the value assigned to a key
pub fn get(&self, k: &K) -> Option<&V> {
match self.vals.binary_search_by(|(k2, _, _)| k2.cmp(k)) {