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

Re-deprecate remove, remove_entry, and take #293

Merged
merged 3 commits into from
Jan 13, 2024

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Jan 12, 2024

It's a frequent point of confusion that these methods disrupt the order
(by swapping the last item), but that choice was made for performance.
The alternative shift_* removals are also disruptive to indices, and
require O(n) updates instead of O(1).

The deprecation notes recommend instead choosing a swap/shift method
explicitly. This doesn't mean that we'll ever actually remove these
deprecated methods, since they are still nice to have when acting as a
drop-in HashMap replacement, but the warning will hopefully help avoid
surprises.

Resolves #241.
Resolves #220.

It's a frequent point of confusion that these methods disrupt the order
(by swapping the last item), but that choice was made for performance.
The alternative `shift_*` removals are also disruptive to indices, and
require O(n) updates instead of O(1).

The deprecation notes recommend instead choosing a swap/shift method
explicitly. This doesn't mean that we'll ever actually _remove_ these
deprecated methods, since they are still nice to have when acting as a
drop-in `HashMap` replacement, but the warning will hopefully help avoid
surprises.
@cuviper cuviper merged commit cd74680 into indexmap-rs:master Jan 13, 2024
14 checks passed
@cuviper cuviper deleted the deprecate-remove branch January 13, 2024 02:04
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

Successfully merging this pull request may close these issues.

Change remove to unstable_remove Update readme to mention shift_remove
1 participant