From dd54d0b2b13ecf1f95e60b107de9af20632335f6 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 6 May 2022 17:14:09 +0200 Subject: Refactor code for apply/revert, implement Update/Apply/RevertLayout --- src/util/crdt/lww_map.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/util') 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)) { -- cgit v1.2.3