-
Notifications
You must be signed in to change notification settings - Fork 60
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 xor and add tests #61
Conversation
cc #33 |
@tbu- could you please elaborate on
Should we rename to |
I don't remember. The blame of the file seems to be wrong due to a repository import. |
Ah right. Since I don't care about this anymore, feel free to disregard this and remove the FIXME. |
By saying you don't care about this, do you mean you do not have an opinion, or do you think we shouldn't change this? I mean, the motivation is good. |
By that I mean that I don't have a skin in the game anymore. I still think the reason is good, but I won't spend time defending that opinion. |
I agree that union/intersection/symmetric difference are terminology for sets and not technically accurate when talking about a BitVec, but I'm not sure if it's worth changing the established API to correct this. Will defer to whatever the maintainers of this repository decide. |
I put to together a script to download crates and search for uses of these methods. In case there are very few uses of these methods, we go through with this. Then, we send PRs to patch for the change. Requirements cargo install cargo-download Script let deps = [];
function handleDeps(res) {
res.on('data', data => { deps.push(JSON.parse(data.toString())) })
}
function grab(page) {
const httpsOpts = { headers: { "User-Agent": "bit-vec crawl by @pczarn" } };
const url = `https://crates.io/api/v1/crates/bit-vec/reverse_dependencies?page=${page}`;
https.get(url, httpsOpts, handleDeps);
}
Array(8).fill().map((_, i) => grab(i + 1));
// ... wait
deps.flatMap(pageD => pageD.versions)
.map(v => v.crate)
.forEach(name =>
exec(`cargo download ${name} > ${name}.tar.gz && tar -xvf ${name}.tar.gz`)
); Search
=> https://gist.github.com/pczarn/1dcf41ee516aea185c71f496930eb06a Turns out we have |
Of course we have no idea about private code. Anyhow, we will rename the methods for v 0.7. Futher possibilities that I can think of are
So, @ifreund please rename and I'll then merge |
Renamed.
I could probably crank those out this weekend. |
Great, feel free to leave the task to me, in case you'd wish to spend time elsewhere. Thank you |
Probably wont get to it till Sunday, if you get to it before then no worries. |
Purpose:
I was using this crate and wanted to take the symmetric difference between two vectors. To my dismay there was no function for this.
Describe the solution:
Implement
symmetric_difference()
to calculate the symmetric difference of two bitvectors, settingself
to the result. The implementation is quite simple, it's just an xor.Add two tests,
test_small_symmetric_difference()
andtest_big_symmetric_difference()
for the new function.