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

Expand removal options #99

Merged
merged 7 commits into from
Aug 28, 2019
Merged

Expand removal options #99

merged 7 commits into from
Aug 28, 2019

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Aug 20, 2019

This aims to make the performance tradeoffs explicit when removing items.

  • New shift_remove and shift_take perform O(n) removal, like Vec::remove
  • The existing swap_* methods already perform like Vec::swap_remove
  • Ambiguous remove and take methods, which currently swap, are deprecated in favor of explicit shift/swap methods.

Fixes #90.

@cuviper
Copy link
Member Author

cuviper commented Aug 20, 2019

As we're talking about a new release, I realized that I was also sitting on these changes in a branch...

@bluss
Copy link
Member

bluss commented Aug 20, 2019

Makes sense. The release is already pushed out, but there can be more releases 🙂

What kind of deprecation is intended? My first thought that it would be a "permanently" deprecated method, since one design guideline was drop-in compatibility with HashMap. So you can switch hashmap implementations easily, and with the warning you can realize you have a choice of removal option.

I'm afraid the deprecation message will be annoying for those that don't mind the current behaviour?

@bluss
Copy link
Member

bluss commented Aug 20, 2019

looks good to me (and adding shift removal is a good idea!)

@cuviper
Copy link
Member Author

cuviper commented Aug 20, 2019

What kind of deprecation is intended? My first thought that it would be a "permanently" deprecated method, since one design guideline was drop-in compatibility with HashMap. So you can switch hashmap implementations easily, and with the warning you can realize you have a choice of removal option.

Yes, this makes sense to me. We have a similar situation on rayon find with a deprecation note. I think later we added the #[doc(hidden)] to avoid clutter.

I'm afraid the deprecation message will be annoying for those that don't mind the current behaviour?

Maybe so, but it's an easy fix to use swap_ or #[allow(deprecated)]. Do you envision folks wanting to flip back and forth? I'd think that would only be during some initial evaluation.

@bluss bluss merged commit eae9abf into indexmap-rs:master Aug 28, 2019
@bluss
Copy link
Member

bluss commented Aug 28, 2019

Thank you for adding this! tests/ directory has no mention of shift_remove 😅 and I'm adding a quickcheck test now for that reason.

@bluss
Copy link
Member

bluss commented Sep 8, 2019

Indexmap 1.2 is released including this feature 🙂

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.

Question about ordered remove
2 participants