summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Perehonchuk <romanp@meta.com>2024-10-01 05:16:42 -0700
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>2024-10-01 05:16:42 -0700
commitc981fa57a6d16af0dff6c147fb357529e2ec1829 (patch)
tree340e8e08e6825494815afeff9db874c41b8f6d3e
parent8ac3bbd026cc407c6621b6eca91907e9d16be580 (diff)
add remove_hashed to small_set
Summary: as per title Reviewed By: stepancheg Differential Revision: D63463050 fbshipit-source-id: a7c95b7e6385dbec7a6923b655b4cd50bd4e2c8e
-rw-r--r--starlark_map/src/small_set.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/starlark_map/src/small_set.rs b/starlark_map/src/small_set.rs
index 73eacc4c..9406e2b1 100644
--- a/starlark_map/src/small_set.rs
+++ b/starlark_map/src/small_set.rs
@@ -256,6 +256,16 @@ impl<T> SmallSet<T> {
Some(self.shift_remove_index_hashed(i)?.into_key())
}
+ /// Remove the entry for the key.
+ ///
+ /// Time complexity of this operation is *O(N)* where *N* is the number of entries in the set.
+ pub fn shift_remove_hashed<Q>(&mut self, key: Hashed<&Q>) -> bool
+ where
+ Q: ?Sized + Equivalent<T>,
+ {
+ self.0.shift_remove_hashed(key).is_some()
+ }
+
/// Insert entry if it doesn't exist.
///
/// Return the resulting entry in the map.