-
Notifications
You must be signed in to change notification settings - Fork 150
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 ordered_remove with O(n)
perf.
#15
Conversation
This does look good to me, just not sure if we need it. I think it is ultimately needed, the OrderMap has a lot of Vec like functionality going already. |
Since some time has passed, you can disregard review comments here. But I'll put down my thoughts so that I don't forget them, for when I come back to this. |
self.index = updater(self.index as usize) as u64; | ||
} else { | ||
let (index, hash) = split_lo_hi(self.index); | ||
self.index = updater(index as usize) as u64 | ((hash as u64) << 32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: does this truncate index correctly
if entry_index >= found { | ||
entry_index - 1 | ||
} else { | ||
entry_index | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If found == 0; entry_index - 1 wraps around
Ok, to not bother you further, I've copied this branch for later reuse to this repo and I'll close the PR. :-) |
I might be understanding the implementation wrong, but I think that order-preserving remove can be implemented by shifting both the
indices
and entryVec
-s, then decrementing all indices after the removed one, then correcting the robin hood property. But maybe I'm wrong, please review carefully @bluss :)Because this operation is
O(n)
compared to the stdO(1)
, I named itordered_remove
so that you're forced to make a conscious decision to preserve order at the expense of performance.If this implementation makes sense, I'm happy to add a couple more commits to update the README and add this operation to
Entry
too.