diff options
Diffstat (limited to 'src/util/sled_counter.rs')
-rw-r--r-- | src/util/sled_counter.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/sled_counter.rs b/src/util/sled_counter.rs index 8af04f50..bc54cea0 100644 --- a/src/util/sled_counter.rs +++ b/src/util/sled_counter.rs @@ -52,6 +52,14 @@ impl SledCountedTree { res } + pub fn remove<K: AsRef<[u8]>>(&self, key: K) -> Result<Option<IVec>> { + let res = self.0.tree.remove(key); + if matches!(res, Ok(Some(_))) { + self.0.len.fetch_sub(1, Ordering::Relaxed); + } + res + } + pub fn pop_min(&self) -> Result<Option<(IVec, IVec)>> { let res = self.0.tree.pop_min(); if let Ok(Some(_)) = &res { |