Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to remove multiple keys at once #3

Closed
kskalski opened this issue Dec 22, 2022 · 3 comments
Closed

Add a way to remove multiple keys at once #3

kskalski opened this issue Dec 22, 2022 · 3 comments

Comments

@kskalski
Copy link

Following the availability of insert/update many it would be nice to also have something like remove_many.
Alternatively (or also) retain function (like in btree map) could be added to support such (and other) use-cases, though that one traverses the whole tree, so it could be too costly if removed set of keys is much smaller than overall keys in the tree.

In my specific use-case I actually need to remove a range of keys, which I imagine might have a fast specialized implementation possible, but I suppose this could as well be a specific scenario possible to exploit in remove_many (as docs mention insert_many being faster on sorted entries).

And thanks for this lib, it looks pretty solid and performs very well!

@estokes
Copy link
Owner

estokes commented Dec 22, 2022

You can do that with update_many, just give it a function that always returns None

You can also implement retain with update_many, just pass the map itself as the elts and you'll visit every key in the map and have the option to remove it.

I'll consider adding convenience functions.

@kskalski
Copy link
Author

Thanks, this seems to work, except for the bug (#4) that I stumbled upon

@estokes
Copy link
Owner

estokes commented Dec 23, 2022

remove_many added as a wrapper around update_many in 1.0.5

@estokes estokes closed this as completed Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants