-
Notifications
You must be signed in to change notification settings - Fork 47
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
Implement custom behavior for PartialEq, Eq, PartialOrd, Ord and Hash #47
base: master
Are you sure you want to change the base?
Conversation
The observed behavior for those traits is the same as the behavior of the standard library's `BTreeSet<usize>`
src/lib.rs
Outdated
{ | ||
#[inline] | ||
fn eq(&self, other: &Self) -> bool { | ||
self.ones().eq(other.ones()) |
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.
While conceptually this algorithm for comparison might be good, I'm afraid that it is slow. Comparison should be based on comparing the blocks, I would guess.
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.
It makes sense!
I've rewrote the code to extract the trimmed slice of blocks instead of using the iterator of ones.
…PartialEq`, `Ord` and `Hash`
This results in a somewhat awkward condition that
We could also update the |
Any chance this behavior will make it to main? I am indeed making |
Hi,
Following up on #44, here is my take on implementing
PartialEq
,Eq
,PartialOrd
,Ord
andHash
. This PR goes beyond the scope of the issue, so all those related traits would be in sync.This is a behavior change that, in practice, makes
FixedBitSet
behave like aBTreeSet<usize>
, whose elements are the items returned byFixedBitSet::ones()
. The change can be breaking for some pieces of code that depended on the old behavior, even if it was undocumented and arguably surprising.For example, using
FixedBitSet
in map will behave differently:Fix #44
Please tell me what you think,
Best regards,