Skip to content

Fix the difference method on bit vectors #4546

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

Merged
merged 1 commit into from
Jan 20, 2013

Conversation

alexcrichton
Copy link
Member

I was looking into the difference method on the bit vector implementations, and I found that it didn't quite align with what I thought of as the difference between two sets.

For SmallBitv, the difference was just the xor of the two vectors, which I'm not really sure what it's supposed to represent. For BigBitv, it almost did the difference except that it added in lots of bits which weren't related to the two bit vectors.

I figured that the difference method should return the set-wise difference:

A / B = { x : x in A and x not in B }

so I updated both of the difference methods to do that and added some tests to do that. If this isn't right, the two implementations (SmallBitv/BigBitv) appear to do different things, so they should probably be unified to one thing anyway.

@thestinger
Copy link
Contributor

+1, xor is equivalent to the symmetric difference rather the difference

@catamorphism
Copy link
Contributor

This was my fault. Thanks!

catamorphism added a commit that referenced this pull request Jan 20, 2013
Fix the difference method on bit vectors
@catamorphism catamorphism merged commit 1cfa01d into rust-lang:incoming Jan 20, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 28, 2021
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 28, 2021
add rust-lang#4546 test

changelog: none
fixed rust-lang#4546

I notice rust-lang#4546 was fixed some time, I just add the tests.
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.

3 participants